Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given
This error means that your query failed for some reason. On failure, mysql_query()
returns false
. It is usually due to a syntax error, missing field/table or no connection to the database.
You should test for the query failing so that you never pass a boolean to mysql_fetch_array()
:
$result = mysql_query("SELECT * FROM bloggings WHERE id ='$idno'");
if($result)
{
while ($row = mysql_fetch_array($result))
{
...
}
}
else
{
// query failed - see mysql_error()
}
There is no problem with having multiple fetch_*
calls on the same page, as long as you are using different result resources (otherwise it will move the pointer forward each time).
Side note: mysql_*
is deprecated, it is recommended to upgrade to MySQLi or PDO. Your code is vulnerable to SQL Injection, use a parameterised query instead of manually interpolating variables into the query.