【发布时间】:2012-12-17 16:06:05
【问题描述】:
您好,我正在尝试通过将变量名称附加到如下 URL 来显示数据库中的特定条目:
echo '<td><a class="index_table" href="includes/view.php?id=$row[id]>$row[Orderno]">
然后在我的 view.php 中我有:
<?php
include 'connect.php';
//Display the Data//
$id=$_GET['id'];
$result=mysql_query("select * from Products where ID=$id");
$row=mysql_fetch_object($result);
echo "<table>";
echo "
<tr bgcolor='#f1f1f1'><td><b>ID</b></td><td>$row->ID</td></tr>
但是,特定的 ID 没有被传递给脚本,并且 view.php 中的表是空白的。将 where 子句更改为 'where id = '1' 时,会显示正确的产品。所以我知道这是有效的。
非常感谢
【问题讨论】:
-
但我想你是通过
http://site.com/view.php?id=23访问它的,对吧? -
@w0rldart 我们都希望如此......
-
如果我传这个参数怎么办:includes/view.php?id=1%20or%20true
-
也容易受到sql注入大多数答案都包含SQL注入!小心点!您需要先将 $id 转换为整数!
-
当我决定将它发送到您的服务器
includes/view.php?id=1%3BDROP%20TABLE%20PRODUCTS%3B时会发生什么?