duanju6788 2013-12-26 22:25
浏览 42
已采纳

为什么mysqli_query被评估为布尔值而不是结果集

What should be a simple mySQL call from PHP is generating the mySQL error mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given

Here's the code:

$updateSQL = "UPDATE content SET type='type1', updated_by='Fred', date_updated = NOW() WHERE id=123";

$mysqli = mysqli_connect($hostname, $username,password, $database);

$update = mysqli_query($mysqli, $updateSQL) or die(mysqli_error($mysqli));
$row_update = mysqli_fetch_assoc($update);
$totalRows_update = mysqli_affected_rows($mysqli);

At first I thought the problem was the or die(mysqli_error($mysqli)), but I get the same error even if I comment that part out. When I check $update with gettype($update), it does show a type of boolean, but I don't understand why.

BTW, the update query itself seems to execute with no problems.

  • 写回答

1条回答 默认 最新

  • douji8549 2013-12-26 22:45
    关注

    Since you are not returning a recordset in you query you don't have to fetch any result, My advice is remove $row_update = mysqli_fetch_assoc($update); line

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

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料