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条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度