dousao8152 2014-09-12 22:51
浏览 40

mysqli_fetch_array问题 - 布尔而不是mysqli_result [重复]

Lately, I have been writing some code for my site. Usually, I have no bother with this bit of code, but it has suddenly started having issues. I am using mysqli_fetch_array to select some values from my database, but it is returning the error:

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given.

I guess what we've all seen this error before, but I cannot seam to get rid of it. The code that it is referring to is as follows:

if (!empty($emailAddressGET) && !empty($passwordGET)) {

    $infoGet = mysqli_query($dbConnect, "SELECT * FROM users WHERE emailAddress = '".$emailAddress."'");

    while ($row = mysqli_fetch_array($infoGet, MYSQLI_ASSOC)) { //BUG LINE

        //Code for setting cookies, checking values etc here

    }
}

How can I prevent this error from happening?

</div>
  • 写回答

1条回答 默认 最新

  • doujue9767 2014-09-12 23:08
    关注

    Basically if you have this problem it means your request is failing. So I suggest you debug your request step by step for instance you can change your request into something like this:

     $infoGet = mysqli_query($dbConnect, "SELECT * FROM users");
    

    If the bug is not showing it means the error is in the condition side. In that case either the field name (emailAddress) doesn't match with the one in your table or the variable $emailAddress contains some un-sanitized information.

    评论

报告相同问题?