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? Link to comment https://forums.phpfreaks.com/topic/58468-solved-mysql_fetch_array-error/ 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? Link to comment https://forums.phpfreaks.com/topic/58468-solved-mysql_fetch_array-error/#findComment-289952 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 Link to comment https://forums.phpfreaks.com/topic/58468-solved-mysql_fetch_array-error/#findComment-289954 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 Link to comment https://forums.phpfreaks.com/topic/58468-solved-mysql_fetch_array-error/#findComment-289955 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.