doupaimo8288
2014-09-16 14:27
浏览 70
已采纳

警告:mysqli_fetch_assoc()期望参数1为mysqli_result,第101行给出null [关闭]

Im not sure why I'm getting this error. Line 101 shows as:

$sql_apr_i="SELECT SUM(total) FROM invoices WHERE YEAR(date_added) = YEAR(CURDATE()) AND MONTH(date_added) = 06 AND estimate = 0 AND user_id = '$user_id'";
$data_apr_i = mysqli_query($connect_db,$sql_apr_i);
$april_invoice = mysqli_fetch_assoc($data_april_i);

What am i doing wrong to get this error?

图片转代码服务由CSDN问答提供 功能建议

我不知道为什么我会收到此错误。 第101行显示为:

  $ sql_apr_i =“SELECT SUM(总计)FROM发票WHERE YEAR(date_added)= YEAR(CURDATE())AND MONTH(date_added)= 06 AND 估计= 0 AND user_id ='$ user_id'“; 
 $ data_apr_i = mysqli_query($ connect_db,$ sql_apr_i); 
 $ april_invoice = mysqli_fetch_assoc($ data_april_i); 
   
 \  n 

我错误地得到了这个错误?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

  • duanniying2342 2014-09-16 14:34
    最佳回答

    You have wrong variable name passed to mysqli_fetch_assoc. Try this:

    $sql_apr_i = "SELECT SUM(total) FROM invoices WHERE YEAR(date_added) = YEAR(CURDATE()) AND MONTH(date_added) = 06 AND estimate = 0 AND user_id = '$user_id'";  
    $data_apr_i = mysqli_query($connect_db, $sql_apr_i);  
    $april_invoice = mysqli_fetch_assoc($data_apr_i);
    
    评论
    解决 无用
    打赏 举报
查看更多回答(2条)

相关推荐 更多相似问题