This question might have been asked before and I apologise if it has. I have tried some solutions to my error but still can't find the solution.
My code is:
$sql = "SELECT S.ID, S.sentence "
. "FROM word I, word2category C, sentence S "
. "WHERE C.category_ID = 10 "
. "AND I.ID = C.word_ID "
. "AND S.word_ID = I.ID "
. "AND S.ID NOT IN (SELECT sentence_ID FROM annotation WHERE IP = '" . $ip . "')"
. "ORDER BY RAND()";
$res = mysql_query($sql);
$row = mysql_fetch_array($res);
$ID = $row["S.ID"];
echo "<input type='hidden' name='ID' value='$ID'/>\n"; // --- get sentence ID to store an annotation later on
$sentence = $row["S.sentence"];
// $sentence = str_replace("£", "£", $sentence);
I'm attempting to retrieve a random sentence which has an ID within the sentence table and is a part of a category in another table (category_id) .
I'm receiving this error:
mysql_fetch_array() expects parameter 1 to be resource, boolean given
I think it's because the $sql query failed (or returned 0 rows). This causes $res to become null/false, and "mysql_fetch_array()" will return that error if $res is null/false. Effectively, the error is saying that it's expecting $res to be a mysql result, but it's actually a Boolean (false).
However, I've looked at it for so long, I can't resolve it :(
Thankyou in advance.