Q:

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in

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

Hello please help me solve this problem
<?PHP

if(isset($_GET["id"]))
    {
        $id= $_GET["id"];}

        echo $id;

    $user_name = "root";
    $password = "";
    $database = "test";
    $server = "127.0.0.1";

$db_handle = mysql_connect($server, $user_name, $password);

$db_found = mysql_select_db($database, $db_handle);

if ($db_found) {

$SQL = "SELECT location FROM core_network WHERE sub_cat= (".$id.")";
   $r=mysql_query($SQL);
    $i=0;
    while($data=mysql_fetch_array($r))
    {
        $result[$i]=$data['location'];
        $i++;
    }
    #print_r($result);

echo $id; is printing normal and i can not find what is the problem
please help me solve this
thanks lot

A:

That error is caused when your query fails. When mysql_query() fails, it returns a boolean false, as opposed to a resource, hence the error :

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

To debug, change you statement to
$r = mysql_query($SQL) or die(mysql_error());

PS - You should not be using mysql_*. Look into PDO. Here's a link to get you started: http://net.tutsplus.com/tutorials/php/php-database-access-are-you-doing-it-correctly/

