I get this error Warning: mysql_fetch_array(): supplied argument is not a valid MySQ开发者_开发百科L result resource
when I changed my code to this
$term = $_POST["term"];
$query = mysql_query("SELECT id FROM planet1 WHERE MATCH (title) AGAINST ('$term')");
while($row = mysql_fetch_array( $query )) {
echo $row['id'],'<br>';
}
This happens when there is an error during the execution of the SQL query :
mysql_query()
returnsfalse
- and that's not a resource as
mysql_fetch_array()
expects.
You should try calling mysql_error()
, to have some information about the error that's caused by the execution of your MySQL :
$query = mysql_query("SELECT id FROM planet1 WHERE MATCH (title) AGAINST ('$term')");
if (!$query) {
echo mysql_error();
die;
}
Note: of course, this echo+die is OK while developping, but should never be present on a production server.
精彩评论