Home >Database >Mysql Tutorial >Why Does My PHP Script Throw a 'mysql_fetch_array(): supplied argument is not a valid MySQL result' Warning?
Invalid Argument in mysql_fetch_array()
Problem Description
Upon executing a PHP script, the following error is encountered:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result [duplicate]
Origin of the Error
This error is typically caused when the $result variable, which is expected to contain a valid MySQL result set, is actually empty or invalid.
Code Snippet
The code snippet causing the issue:
$connector = new DbConnector(); $result = $connector->query('SELECT title,content FROM staff_vacancies ORDER BY ordering LIMIT 0,100'); while ($row = $connector->fetchArray($result)){ echo $row['title'].'</h3>'; echo $row['content']; }
Possible Causes
Here are possible causes for the invalid $result variable:
Solution
To resolve this issue, consider the following steps:
The above is the detailed content of Why Does My PHP Script Throw a 'mysql_fetch_array(): supplied argument is not a valid MySQL result' Warning?. For more information, please follow other related articles on the PHP Chinese website!