du8589840 2013-09-17 15:13
浏览 88
已采纳

在另一个PHP页面中打印$ _GET值

I have the following. My issue is when the 'Buy' link is clicked on index.php, on the paynow.php page does not show anything. Where have I gone wrong?

P.S: Theunitprice echos fine. So I know that there is no issue is pulling data from the SQL database.

index.php

$sql_content = "show columns from cameras";
$get_res = mysql_query($sql_content);
$cols = mysql_num_rows($get_res);
$page = $_REQUEST['page'];
$start = ($page-1)*8;
$sql_content1 = "select * from cameras limit $start,$per_page";
$query = mysql_query($sql_content1);

$j=0;
while ($rows = mysql_fetch_assoc($query))
{
?>
<link href="style1.css" rel="stylesheet" type="text/css" />

<div id='mainFrame'>
    <div id='totalFrame'>
        <div id='priceX'><b>Rs.&nbsp;</b>&nbsp;<?php echo $rows['unitprice'];?></div><!--pricex-->
        <div id='buynow'><a href="paynow.php?id="<?php echo $rows['model']; ?>">Buy</a></div>
    </div><!--close total frame-->
</div>
<?php

paynow.php

<?php
print $_GET["id"]; 
?>
  • 写回答

4条回答 默认 最新

  • dongza1708 2013-09-17 15:20
    关注

    To start with, you should immediately stop using any mysql_* functions. Take a look here: http://php.net/manual/en/function.mysql-query.php

    The interface is now deprecated and you should use PDO_MySQL or MySQLi.

    You also have a potential SQL injection vulnerability in your code as you're not sanitising the input to the SQL query.

    For your question, the syntax highlighting right here on SO has highlighted your problem, you have an extra " in your code:

    <div id='buynow'><a href="paynow.php?id="<?php echo $rows['model']; ?>">Buy</a></div>
    

    Should be this:

    <div id='buynow'><a href="paynow.php?id=<?php echo $rows['model']; ?>">Buy</a></div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么