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 请问Ubuntu要怎么安装chrome呀?
  • ¥15 视频编码 十六进制问题
  • ¥15 Xsheii7我安装这个文件的时候跳出来另一个文件已锁定文件的无一部分进程无法访问。这个该怎么解决
  • ¥15 unity terrain打包后地形错位,跟建筑不在同一个位置,怎么办
  • ¥15 FileNotFoundError 解决方案
  • ¥15 uniapp实现如下图的图表功能
  • ¥15 u-subsection如何修改相邻两个节点样式
  • ¥30 vs2010开发 WFP(windows filtering platform)
  • ¥15 服务端控制goose报文控制块的发布问题
  • ¥15 学习指导与未来导向啊