Jump to content

[SOLVED] Database Function Problems


IronWarrior

Recommended Posts

The following code:

 

	function getItemsForSaleOfCatagory($itemCatagory)
{
	$query  = "SELECT vehicleID,vehicleName FROM vehiclesForSale WHERE vehicleCatagory = $itemCatagory AND isActive = 1";
	$result = mysql_query($query);
	if (!mysql_affected_rows($result)==0)
	{
		while($resultRow = mysql_fetch_array($result))
		{	
				echo"<br />";
				echo"<a href=\"index.php?page=browseSingleItem&vehicleID=".$resultRow[vehicleID]."\">";
					echo"$resultRow[vehicleName]";
				echo"</a>";	
		}
	}
	else
	{
		echo "There are curently not vehicles for sale under this category";
	}
}

 

Returns the following error:

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\-\siteConfiguration.php on line 94

Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in C:\AppServ\www\-\siteConfiguration.php on line 33
There are curently not vehicles for sale under this category
Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in C:\AppServ\www\-\siteConfiguration.php on line 46

 

I have added the affected rows in order not to run the query if there is no relevant data in the database...

Link to comment
https://forums.phpfreaks.com/topic/121371-solved-database-function-problems/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.