IronWarrior Posted August 26, 2008 Share Posted August 26, 2008 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... Quote Link to comment https://forums.phpfreaks.com/topic/121371-solved-database-function-problems/ Share on other sites More sharing options...
haku Posted August 26, 2008 Share Posted August 26, 2008 You can't use mysql_affected_rows on a SELECT result. It only works on update and delete I believe. Quote Link to comment https://forums.phpfreaks.com/topic/121371-solved-database-function-problems/#findComment-625786 Share on other sites More sharing options...
IronWarrior Posted August 26, 2008 Author Share Posted August 26, 2008 Reading you loud and clear, right have modified affected rows to num rows, but we are still having problems. Quote Link to comment https://forums.phpfreaks.com/topic/121371-solved-database-function-problems/#findComment-625787 Share on other sites More sharing options...
haku Posted August 26, 2008 Share Posted August 26, 2008 You probably have a problem in your msyql query syntax then, and it's not returning a result. Echo mysql_error() after the query and see what you get. Quote Link to comment https://forums.phpfreaks.com/topic/121371-solved-database-function-problems/#findComment-625788 Share on other sites More sharing options...
IronWarrior Posted August 26, 2008 Author Share Posted August 26, 2008 Thanks for the help I have managed to get it working, did a mysql_error() and got the issue, which was an incorrectly spelt category name Quote Link to comment https://forums.phpfreaks.com/topic/121371-solved-database-function-problems/#findComment-625830 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.