...

View Full Version : php not printing my mysql output [ was what's wrong with this? ]



fenderocker
07-24-2006, 06:50 PM
it doesn't output the message and date variables, only the part that says "Posted on : " and "News : " and the "<br />"s. Help! I know that I could connect to the db correctly! also I don't get the could not query message!


$result = mysql_query("SELECT * FROM news ORDER BY id DESC LIMIT 0 , 10") OR die("Could not query.");
while ($row = mysql_fetch_object($result)) {
echo "Posted on : ";
echo $row['date'];
echo "<br />";
echo "News : ";
echo $row['message'];
echo "<br /><br />";
}

guelphdad
07-24-2006, 06:55 PM
Please use proper thread titles, it is helpful to those looking to assist you.

guelphdad
07-24-2006, 06:57 PM
Try changing
mysql_fetch_object
to
mysql_fetch_array

I think with mysql_fetch_object you have to use pointer notation to refer to your fields whereas mysql_fetch_array you can refer to them as you have above.

fenderocker
07-24-2006, 10:06 PM
Thanks! that fixed it!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum