作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
当我上传到实时服务器时出现以下错误。它在本地主机上工作正常,我认为这很奇怪。
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;
}
最佳答案
您应该将 $stmt
放入您的 if 子句中。有可能 if (false) and still get to your $stmt->close();
关于php - fatal error : Call to a member function close() on a non-object. MySQLi 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9722159/
我是一名优秀的程序员,十分优秀!