So I have a MySQL database that I’m trying to query, and the query keeps failing. I know this because immediately after my query I call mysql_fetch_array() to parse the result of the query into something usable. At this point, however, my script pukes, saying that mysql_fetch_array() expects a resource, but a boolean was given. The only way this could have happened is that mysql_query() failed and returned false instead of a resource. My relevant files are here.
The first file contains my MySQL configuration.
The second file contains the include file that contains the function with the problem.
The third file contains the actual webpage that calls the function with the problem.
The fourth file is completely unrelated, but since I couldn’t post each of these links individually (I don’t have enough rep points yet), I had to give you all of them at once.
mysql_fetch_array() does require a valid resource to fetch something. Before I tell you your soluction, I would like to point that
MYSQL_* API is now deprecated So I will tell you using
$query = "YOUR QUERY STATEMENT"; $result = mysqli_query($query); // Now this statement should return a mysql resource $row = mysqli_fetch_assoc($result);