dt1888 2016-03-22 02:59
浏览 62
已采纳

为什么这个SQL语句失败了? 在非对象上调用成员函数bind_param()

I am running on Host Gator and using a mySQL backend, with phpMyAdmin as a GUI.

I am coding in PHP.

I have had no issues performing standard prepare statements, but all of a sudden, with my first delete statement, there seems to be an error. I cannot spot or debug it. The following code is where the error occurs.

    //Error occurs right here
    if(!($sql = $con->prepare("DELETE FROM quoteItems WHERE quoteID=?")))
    { echo "FAIL - Prepare failed: (" . $con->errno . ") " . $con->error;}

    if(!$sql->bind_param('i', $quoteID))
    {echo "FAIL - Binding parameters failed: (" . $sql->errno . ") " . $sql->error;}

    if(!$sql->execute())
    {echo "FAIL - Execute failed: (" . $sql->errno . ") " . $sql->error;}

The output of var_dump($quoteID); gives string "44" in my current situation.

The error message that is produced is FAIL - Prepare failed:(0) Fatal Error: Call to a member function bind_param() on a non-object

  • 写回答

1条回答 默认 最新

  • douwa1304 2017-02-08 20:59
    关注

    This question was correctly solved by @Sean in the comments under the OP.

    Is $con a valid mysqli object? Do you have DELETE rights for this db user?

    The user did not have DELETE rights - giving the user this right solved the issue. The $con object was a valid object.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵