【发布时间】:2015-10-22 16:36:41
【问题描述】:
这是我的代码...它是关于使用 php mysqli 扩展的
<?php
error_reporting(E_ALL);
$db = new mysqli("localhost","root","","dee");
if ($db->connect_errno)
{
die('Unable to connect to database');
}
mysqli_set_charset($db,"utf8");
$storeid=4;
$categoryid=6;
$statement_store = $db->prepare('SELECT * FROM tbl_store WHERE store_id=?');
$statement_store->bind_param('i',$storeid);
$statement_store->execute();
$statement_store->store_result();//---------------(1)
$statement_store->bind_result($store_id,$store_name,$store_description,$store_image,$store_open,$store_close,$store_foldername);
$statement_store->fetch();
$store = $store_name;
//$statement_store->close();//--------------(2)
$statement_category = $db->prepare('SELECT * FROM tbl_category WHERE category_id=?');
$statement_category->bind_param('i',$categoryid);
$statement_category->execute();
$statement_category->bind_result($category_id,$category_name);
$statement_category->fetch();
$category = $category_name;
echo $store;
echo '<br>';
echo $category;
?>
- 致命错误:在布尔错误上调用成员函数 bind_param() 给出 当不使用 (1) 和 (2) 时
- 当使用 (1) 或 (2) 时不给出错误
- 同时使用 (1) 和 (2) 时不会出错
谁能告诉我这里发生了什么?
【问题讨论】:
标签: php mysqli prepared-statement