所以这是导致此时头疼的代码。得到此错误:
致命错误:调用未定义的方法mysqli_result :: execute()
不确定我在哪里做错了:
$mysqli_load = new mysqli(HOST, USER, PASS, DB);
$query = 'SELECT `id`, `call_taker`, `call_time`, `call_type`, `call_priority`, `call_location`, `call_city`, `reporter_name`, `reporter_num`, `call_info` FROM `calls`';
$sql = mysqli_query($mysqli_load, $query) or die($mysqli_load->error);
$sql->execute() or die($mysqli_load->error);
$sql->bind_result($c_id, $c_taker, $c_time, $c_type, $c_priority, $c_location, $c_city, $r_name, $r_num, $c_info) or die($mysqli_load->error);
while($row = mysqli_fetch_assoc($sql)){
答案 0 :(得分:0)
mysqli_query正在返回mysqli_result object,它具有操作查询结果的方法,如fetch,fetch_object等,因为它是结果。此时已经执行了查询。
mysqli::bind_result
的使用位置错误,应该在语句中运行。应该完全避免,因为它已在PHP5.4
中删除。
如何以这种方式制定它:
$mysqli_load = new mysqli(HOST, USER, PASS, DB);
$query = 'SELECT `id`, `call_taker`, `call_time`, `call_type`, `call_priority`, `call_location`, `call_city`, `reporter_name`, `reporter_num`, `call_info` FROM `calls`';
$sql = mysqli_query($mysqli_load, $query) or die($mysqli_load->error);
while ($row = mysqli_fetch_assoc($sql)) {
// data manipulation
}
// and possibly close connection
无需执行和绑定任何内容。
为了将来参考,如果您的查询需要一些用户输入,请查看How can I prevent SQL injection in PHP?