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 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥50 大二 微机原理 课程design 有偿