dsux90368 2012-09-26 21:14
浏览 63
已采纳

MySQLi调用非对象的成员函数bind_param()错误[duplicate]

This question already has an answer here:

This is weird. I'm only adding one variable to the prepare() and bind_result() and it causes an error. Here's the code that worked:

$id = $_GET['id'];
$result = $mysqli->prepare("SELECT YiD, Title FROM Videos WHERE iD = ?");
$result->bind_param("s",$id);
$result->bind_result($youtubeid, $youtubetitle);
$result->execute();
$result->store_result();
$result->fetch();

Now here's the code that didn't work:

$id = $_GET['id'];
$result = $mysqli->prepare("SELECT YiD, Title, Desc FROM Videos WHERE iD = ?");
$result->bind_param("s",$id);
$result->bind_result($youtubeid, $youtubetitle, $youtubedesc);
$result->execute();
$result->store_result();
$result->fetch();

and it gave me this error - Fatal error: Call to a member function bind_param() on a non-object in /home/content/77/9901377/html/video.php on line 23

Line 23 is the bind_param("s",$id)

I've called the database correctly and everything works in the first code, but when I add some more variables to the code it doesn't work.

</div>
  • 写回答

2条回答 默认 最新

  • dsadsa123111 2012-09-26 21:21
    关注

    Desc is a MySQL reserved word. If you want to use it as a column or table name, you must enclose it in backticks (`)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?