【发布时间】:2014-06-26 19:24:45
【问题描述】:
这是我的代码:
<?php
$product_id = $_GET['id'];
if($connect = mysqli_connect('localhost','root','','accounting')){
$sql = "SELECT * FROM inventory WHERE product_id='$product_id'";
$query = mysqli_query($connect,$sql);
mysqli_free_result($query);
mysqli_close($connect);
}else{
print "Connection failed";
}
while ( $fetch = mysqli_fetch_object($query) ) {
print $fetch->id;
}
?>
我不知道为什么我的代码不起作用!,它似乎是正确的。 帮帮我:)
【问题讨论】:
-
帮帮我不会帮你找到答案...
-
可能存在许多问题:凭据错误、查询语法错误、查询不存在的列、无效/不存在的“
product_id”、未正确安装的 PHP,或者可能是事实上,没有像mysqli_free_result()这样的功能。如果没有更多上下文,这里没有人可能可能知道您的具体问题是什么。 -
@esqew 显然有php.net/manual/en/mysqli-result.free.php
-
在查询后将
var_dump($product_id);放在$product_id = $_GET['id'];和var_dump($sql);下,看看有什么回声。另外,将错误报告添加到文件顶部error_reporting(E_ALL); ini_set('display_errors', 1);看看是否会产生任何错误。 -
@Fred-ii- 不再阻塞此评论线程,但我put in a bug for this。