Hi all,
I'm a newbie so please forgive me! I've tried finding the answer to this problem for a good couple of hours but not got anywhere...
I'm getting the following error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\chris\petdisplay.php on line 28
Can anybody suggest what the problem might be? I'm working through my PHP + MySQL For Dummies book, but unfortunately the book doesn't offer any troubleshooting at this point! I've retyped the code and checked it many times but can't fathom the problem!Code:<?php /* Program: petdisplay.php * Desc: Displays all pets in selected category. * / ?> <html> <head><title>Pet Catalog</title></head> <body> <?php $user="catalog"; $host="localhost"; $password="p4ssword"; $database = "PetCatalog"; $connection = mysql_connect($host,$user,$password) or die ("Couldn't connect to server"); $db = mysql_select_db($database,$connection) or die ("Couldn't select database"); $pettype = "horse"; //horse was typed in a form by user $query = "SELECT * FROM Pet WHERE petType='$pettype'"; $result = mysql_query($query) or die ("Couldn't execute query."); /* Display results in a table */ $pettype = ucfirst($pettype)."s"; echo "<h1>$pettype</h1>"; echo "<table cellspacing='15'>"; echo "<tr><td colspan='3'><hr></td></tr>"; while ($row = mysql_fetch_array($result)) { extract($row); $f_price = number_format($price,2); echo "<tr>\n <td>$petName</td>\n <td>$PetDescription</td>\n <td align='right'>\$$f_price</td>\n </tr>\n"; echo "<tr><td colspan='3'><hr></td></tr>\n"; } echo "</table>\n"; ?> </body></html>
The offending line (28) is:
Many thanks in anticipation of any help!Code:while ($row = mysql_fetch_array($result))![]()




Reply With Quote



Bookmarks