douhao3562 2018-10-16 04:00
浏览 145
已采纳

mysqli_query和while循环[重复]的PHP语法错误

This question already has an answer here:

Please help me out what I am doing wrong in this block of code/script:

 $product=array();
 if($result=mysqli_query($con,"SELECT * FROM `INS_PAN`")
 {
     while($object==mysqli_fetch_object($result)):
         $product[]=$object;
     endwhile;
     mysqli_free_result($result);
 }

Please correct me out, I am Rookie in PHP.

</div>
  • 写回答

1条回答 默认 最新

  • doushan3511 2018-10-16 04:03
    关注

    you have an error in this line if($result=mysqli_query($con,"SELECT * FROM INS_PAN"). you have missing ) close brackets. and also = equal sign errors in

    replace above line with this:

    $result=mysqli_query($con,"SELECT * FROM `INS_PAN`");
        if($result){
           //your code
        }
    

    Some Suggestion: The best practices to avoid brackets error. when you open brackets ( or { then you should immediately closed the brackets before any code or statement.

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

报告相同问题?