0

Possible Duplicate:
mysql_fetch_array() expects parameter 1 to be resource, boolean given in select

I have a problem looping through a sql query , here is my code that reads each result from the query result.

    // Check if PCID is already inside DB > ActivePCS
    $CHECK_PCID_Q = mysql_query("SELECT * FROM ActivePCS where CustomerID='$CIDX' AND Customer_Email='$EMAIL' AND Pc_Name='$PCID'");
    //$CHECK_PCID_R = mysql_fetch_array($CHECK_PCID_Q);

    $isfound = 0;
    while($CHECK_PCID_R = mysql_fetch_array($CHECK_PCID_Q)) // <<-- error is here
    {
        if($CHECK_PCID_R['PC_Name'] == $PCID)
        {
            $isfound = 1;
            break;
        }
    }

But i get that error :

warning mysql_fetch_array() expects parameter 1 to be resource boolean given

In my localhost it works fine , but when i uploaded it to my server it gave that error.

EDIT : Sorry my bad , my query had the wrong table name.....

Community
  • 1
  • 1
BOSS
  • 1,786
  • 11
  • 32
  • 60

1 Answers1

6

Check if your database connection is working. The result you get means your variable contains FALSE instead of the result, which happens when connection hasn't been established.

Often this is the result of the wrong / misspelled database name in the mysqli_connect, but it could be also some other errors in the code that establishes the connection.

Dimitri Vorontzov
  • 7,364
  • 12
  • 47
  • 76