Skip to content Skip to sidebar Skip to footer

How To Resolve Mysql_fetch_assoc() Problems

Possible Duplicate: mysql_fetch_array() expects parameter 1 to be resource, boolean given in select When i use the code below, im getting this error: Warning: mysql_fetch_assoc()

Solution 1:

this is not mysql_fetch_assoc problem but query problem
make it

$sql="SELECT * FROM users";
$result = mysql_query($sql) or trigger_error(mysql_error().$sql); 

and see actual error


Solution 2:

Check the error messages of MySQL using mysql_error:

<?php
$result = mysql_query('SELECT * FROM users');
$error = mysql_error();
if ($error != '')
    die($error);
?>

Solution 3:

Usually I do the Mysql connecting like this:

$con = mysql_connect("host","user","passwd");
if (!$con)
{
   die('Could not connect: ' . mysql_error());
}

Post a Comment for "How To Resolve Mysql_fetch_assoc() Problems"