im making a quick code for my site so that on 1 page it will get the lastest 5 posts made. now im using the same code as i did for the ful news and it gives me this error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/httpd/vhosts/metalstation1.com/httpdocs/News2/quick_news.php on line 6
now this code will work on the ful news but noit the quick 1 :S
heres the code to the quick news
PHP Code:
include "config.php";
$db_connection = mysql_connect ($DB_HOST, $DB_USER, $DB_PASS) or die ('Could not connect to MySQL: ' . mysql_error());
mysql_select_db ($DB_NAME) or die ('Could not Select Database: ' . mysql_error());
$query = "SELECT * FROM News_Posts ORDER BY Date DESC LIMIT 5";
while ($row = mysql_fetch_array ($query, MYSQL_ASSOC)) {
list($year,$month,$day)= explode('-', $row['Date']);
$newdate =date("m-j-Y", mktime(0, 0, 0, $month, $day, $year));
echo "<CENTER>";
echo "<B>{$row['Subject']}</B> -Posted By: {$row['Username']} on $newdate<BR><BR>";
$msg = str_replace("\n","<br>", $row['Body']);
echo $msg;