donglv5269 2019-05-24 02:19
浏览 176
已采纳

致命错误:未捕获错误:调用未定义函数mysql_close()

I'm learning about MySQL prepare statement and when I run the following code, I get the PHP Fatal error: Uncaught Error: Call to undefined function mysql_close(). The output is correct and I just can't figure out why such an error occurs. Thanks for your time!

$conn3 = new mysqli(DB_HOST,DB_USERNAME,DB_PASSWORD,DB_NAME);

$event_type = $jarray['event_type'];
$key = "submission";

$search = $conn3->prepare("SELECT * FROM metadb USE INDEX(field_id) WHERE event_type = ? AND event_field = ?");
$search->bind_param('ss', $event_type, $key); 
$search->execute();
$search->store_result();

echo $search->num_rows;

mysql_close($conn3);
  • 写回答

1条回答 默认 最新

  • dryl34156 2019-05-24 02:22
    关注

    Use $conn3->close(); instead of mysql_close($conn3);

    You are using mysqli to open connection and then trying to close connection using mysql.

    Suggestion : You are mixing mysqliobject oriented and procedural in your code I will suggest you to stick with one(preferably Object Oriented). I will also suggest you to start using PDO instead of mysqli. reason explained here

    For more detailed information about mysqli you can refer this documentation.

    For more detailed information about PDO you can refer this documentation.

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

报告相同问题?

悬赏问题

  • ¥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键失灵