I am trying to import MySQL data into PHP through the WordPress PHP Snippet plugin. For whatever reason I keep getting error ‘mysql_fetch_array() expects parameter 1 to be resource, boolean’.
My code is as follows:
Connection
[insert_php]
$conn = mysql_connect("localhost", "albert", "notrealpassword") or die
(mysql_error());
PHP
mysql_select_db('mydatabase');
$query = "SELECT * FROM mytable";
$result = mysql_query($query);
while ($subjectone = mysql_fetch_array($result))
{echo $subjectone['dataintable'];}
[/insert_php]
It is because before the last result the answer of mysql_fetch_array is array but while waits for bolean.
Also probably you know it is better to use new MySQLi functions