Jump to content

[SOLVED] mysql_fetch_array() error


odetron

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.