致命错误:调用非对象上的成员函数close()。 MySQLi问题 [英] Fatal error: Call to a member function close() on a non-object. MySQLi issue
本文介绍了致命错误:调用非对象上的成员函数close()。 MySQLi问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的第一篇文章,所以去容易对我^ _ ^
this is my first post so go easy on me ^_^
我上传到实时服务器时遇到以下错误。它工作确定在localhost,我认为是奇怪。任何帮助将非常感激。
I have been getting the following error when i uploaded to a live server. It works ok on localhost which i thought was strange. Any help would be greatly appreciated.
Fatal error: Call to a member function close() on a non-object....
它指的行
$stmt->close();
与数据库的连接
$connection=new mysqli($MYSQL_HOST,$MYSQL_USER,$MYSQL_PASS,$DB)or die(mysqli_error($connection));
类本身。
function getTimes(){ //this method just pulls the results of the query and returns them as an array
global $connection;
$route = $this->route;
$station = $this->station;
$day = $this->day;
// create a prepared statement
if ($stmt = $connection->prepare("select time from timetable where route=? and day=? and station=?")) {
$stmt->bind_param("sss", $route, $day, $station); // bind parameters for markers
$stmt->execute(); //execute query
$stmt->bind_result($col1); //bind result variables
while ($stmt->fetch()){
$results[]=$col1;
}
}
$stmt->close();//close statement
return $results;
}
推荐答案
$ c> $ stmt into you if子句。有一个可能性,如果(false)并仍然得到你的 $ stmt-> close();
You should put $stmt
into you if clause. There is a possiblity that if (false) and still get to your $stmt->close();
这篇关于致命错误:调用非对象上的成员函数close()。 MySQLi问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文