dongnan1989 2016-05-26 00:30
浏览 55
已采纳

PHP mysql错误,无法INSERT到数据库

I have these lines of PHP code:

$sql2 = "INSERT INTO TableName ... " //an example, line is very long
error_log($sql2);
$result2 = $this->conn->query($sql2); //line 81

I get this error in PHP error log:

PHP Warning:  mysqli::query(): Couldn't fetch mysqli in /volume1/web/DB_Functions.php on line 81

My first idea was that my $sql2 string is not valid, but when I copied it from PHP error log and pasted it to PhpMyAdmin as SQL it works pretty well, what could be wrong?

  • 写回答

1条回答 默认 最新

  • dsajdgjadwqe3247382 2016-05-26 00:46
    关注

    I think it is because when you close the database connection the first time, you forget to do:

    unset($this->conn);
    

    And then when you try connecting to the database again, it craps out because it is still set to the closed connection. Originally referenced from: Warning: mysqli_query(): Couldn't fetch mysqli

    Hope it solve your problem!

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

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部