Possible Duplicate:
mysql_fetch_array() expects parameter 1 to be resource, boolean given in select
$id=(int)$_GET["id"];
$result = mysql_query("SELECT questionstable.*, categorytable.name
FROM questionstable
INNER JOIN categorytable
ON categorytable.id = questionstable.category
WHERE id=$id");
$row = mysql_fetch_assoc($result);
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\Program Files\EasyPHP-5.3.4.0\www\scsoru.php on line 33
mysql_query
returns false on failure, so the fact that you're getting a boolean means the query was unsuccessful. You should always check to see if the result was false before going any further (see the above link for more details).
Try running the SQL query in PHPMyAdmin to see what the error is. I'm guessing it's because you're using WHERE id
when you should be using WHERE questionstable.id
.
You have a SQL error, then the $result will be null. You can verify this with:
$result = mysql_query("your quesry");
if (!$result) {
die('Invalid query: ' . mysql_error());
}
And it will print more information about what went wrong.
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in
If you find this error message it means that your query is wrong. Copy paste the query in phpMyAdmin and check if it is producing any result.
Always try the query in phpMyAdmin >>SQL tab and if it producing correct result then try it on your code.