Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Supplied argument is not a valid MySQL result resource

Status
Not open for further replies.

BigBadDave

Programmer
May 31, 2001
1,069
EU
My code worked fine on server A then i moved it to server B and it stoped working and I got this error :


Warning: Supplied argument is not a valid MySQL result resource in /usr/home/m/a/markszone/public_html/shop/search.php on line 24


any ideas?? Regards

Big Bad Dave

logo.gif


flashtektips@hotmail.com
 
Means your mysql_query() is bombing.

So, something you're passing there is not kosher.

Check your passwords, servername, query syntax
 
You should never see that error. If you do, it means you aren't doing enough error checking in your code.

This code sample that follows shows the error checking and error reporting I recommend you perform. It will also perform the first two troubleshooting steps I recommend you take when you dealing with MySQL calls: displaying the query and displaying the error from MySQL.

[tt]
Code:
$dbh = mysql_connect ("myserver", "myuserid", "mypassword");

if ($dbh !== FALSE)
{
	$result = mysql_select_db ("mydatabase", $dbh);
	if ($result !== FALSE)
	{
		$query = "SELECT myfield FROM mytable";
		$rh = mysql_query ($query);
		if ($rh !== FALSE)
		{
			while ($myrow = mysql_fetch_array ($rh, MYSQL_ASSOC))
			{
				// process the data returned from the database.
			}
		}
		else
		{
			print $query;
			print &quot;<br>&quot;;
			print mysql_error();
			die();
		}
	}
	else
	{
		print mysql_error();
		die();
	}
}
else
{
	print mysql_error();
	die();
}
[/tt] ______________________________________________________________________
TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top