Ameslee Posted April 20, 2006 Share Posted April 20, 2006 Can anyone tell me why the code below is displaying this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/tafeamy/public_html/project/Klever Kids/display_events.php on line 113 [code]<td><h1>Events Details</h1> <table width=100% height=10% border=1 align=center cellpadding=0> <tr> <td id=headings width=20% align=center>Event</div></td> <td id=headings width=10% align=center>Date</div></td> <td id=headings width=30% align=center>Cost</div></td> <td id=headings width=15% align=center>Other Info</div></td> <td id=headings width=15% align=center>Contact Person</div></td> <td id=headings width=15% align=center>Contact Number</div></td> <td id=headings width=15% align=center>Mobile</div></td> </tr></table> <?php $hostname = localhost; $username = tafeamy_amy; $password = feathers; $conn = mysql_connect($hostname, $username, $password) or die(mysql_error()); $connection = mysql_select_db("tafeamy_project", $conn); $query = "SELECT event, date, cost, otherinfo, contactperson, number, mobile FROM events"; $mysql_result=mysql_query($query,$conn); while ($rows = mysql_fetch_array($mysql_result)) { $event = $rows['event']; $date = $rows['date']; $cost = $rows['cost']; $otherinfo = $rows['otherinfo']; $contactperson = $rows['contactperson']; $number = $rows['number']; $mobile = $rows['mobile']; echo("<table width=100% border=0 cellpadding=0 cellspacing=0> <tr> <td width=20%>$event</td> <td width=25%>$date</td> <td width=25%>$cost</td> <td width=25%>$otherinfo</td> <td width=25%>$contactperson</td> <td width=25%>$number</td> <td width=25%>$mobile</td> </tr> </table>"); } ?>[/code][b]EDIT BY OBER: PLEASE USE CODE TAGS WHEN POSTING CODE AND THINK ABOUT WHERE YOU ARE POSTING.[/b] Quote Link to comment Share on other sites More sharing options...
ober Posted April 20, 2006 Share Posted April 20, 2006 I have moved this thread to PHP Help.The only reason that error occurs is if you have something wrong with your query. I suggest you run the query directly against the MySQL database (phpmyadmin or any of the MySQL tools) to see if it returns valid results. Also make sure that your connection works properly.Also keep in mind that "date" is a very poor choice for a column name since it is a function name in PHP and is a datatype in many systems. "number" is also a relatively poor choice. Quote Link to comment Share on other sites More sharing options...
Ameslee Posted April 21, 2006 Author Share Posted April 21, 2006 the thing is that the php was working on other pages and now it is not working on this one! so it is not my choice of names that isnt making it work. Quote Link to comment 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.