mysql_fetch_array(): supplied argument is not a valid MySQL result resource in

Hello,

i get this error

mysql_fetch_array(): supplied argument is not a valid MySQL result resource in … line 20

this is my php code

[php]<?

session_start();

if ($_SESSION[‘user’])
{

include "connect2.php";

	$user = ($_SESSION['user']);
	
		if ($result)
		{
		echo 'Could not run query: ' . mysql_error();
		exit;
		}
	
		$result = mysql_query("SELECT * FORM `$user` ");
	
		while($row = mysql_fetch_array($result))
		{
			echo $row['jaar'];	
		}

	}
	else
	{
	echo'Go away!';
	}  

?>[/php]

Do you know that the connect2.php file connects to the database successfully?

If you do, does the table exist (the one that is taken from $_SESSION[‘user’])?

You have also placed the code that tests if the query has failed before running the query.

[php] if ($result)
{
echo 'Could not run query: ’ . mysql_error();
exit;
}[/php]

Should be changed to:

[php] if ($result == false)
{
echo 'Could not run query: ’ . mysql_error();
exit;
}[/php]

And moved to after:

			$result = mysql_query("SELECT * FORM `$user` ");
Sponsor our Newsletter | Privacy Policy | Terms of Service