odetron Posted July 4, 2007 Share Posted July 4, 2007 I was useing the news system code on this site yet im haveing trouble when running part of it. <?php $db_host = "xxxxxxx"; $db_username = "xxxxxxxx"; $db_password = "xxxxxxx"; $db_name = "xxxxxxx"; mysql_connect($db_host,$db_username,$db_password) or die(mysql_error()); mysql_select_db($db_name) or die(mysql_error()); $query = "SELECT name, subject, message, date FROM news order by date DESC"; $result = mysql_query($query); echo "<br><center>"; while($r=mysql_fetch_array($result)) { echo "<tr>"; echo "<td bgcolor='#FFFFFF'><h10>// $r[subject]<HR color='#660000'></td>"; echo "</tr>"; echo "<tr>"; echo "<td bgcolor='#FFFFFF'>$r[message]<HR color='#660000'></h10></td>"; echo "</tr>"; echo "<tr>"; echo "<td bgcolor='#FFFFFF'>Posted By: $r[name]</a> $r[date]<br><br><br></td>"; echo "</tr>"; } echo "</table>"; ?> Im haveing trouble running line 17. It looks right yet I get this message: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource How can I fix this? Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 4, 2007 Share Posted July 4, 2007 while($r=mysql_fetch_array($result)) first remove those what are those for? Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 4, 2007 Share Posted July 4, 2007 while($r=mysql_fetch_array($result)) first remove those what are those for? sorry wrong post Quote Link to comment Share on other sites More sharing options...
Barand Posted July 4, 2007 Share Posted July 4, 2007 use $result = mysql_query($query) or die (mysql_error()); to report why the query is failing 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.