【发布时间】:2017-01-04 21:29:48
【问题描述】:
我的代码有问题吗,它看起来与 php 页面上的示例一模一样,但它给了我这个错误Fatal error: Call to a member function bindParam() on a non-object in /Applications/XAMPP/xamppfiles/htdocs/videosharing/index.php on line 68
$hi = 'hi';
$limit = 4;
$isi = 1;
$query = "SELECT `videoname`,`username`,`videourl`,`uploaddate`,`duration`,`views`,`tags` FROM `videolist` WHERE `tags` = :atagz ";
$stmt = $connection->prepare($query);
$stmt->bindParam(':atagz',$hi);
【问题讨论】:
-
你的连接好吗?
-
连接良好,使用标准方法没有任何问题
-
告诉我们你在哪里启动 $connection 对象; 99% 确定您的错误存在。
-
$connection 来自 db.php require('db.php');然后我添加全局 $connection;里面的 db.php = $connection = new mysqli('localhost','root','','videosharingdatabase');