I'm making a very simple news script and right now all I want to do is insert & display results to the database.
Here's my code so far.
<? $frontpagelimit = "5"; $dbconnect = mysql_connect ("localhost", "user", "pass") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("db"); $query = "SELECT * FROM news ORDER BY id DESC LIMIT $frontpagelimit"; mysql_query($query); $row = mysql_fetch_object($query); echo $row->newsbody; ?>
What I'm trying to do at this stage is get the newsbody that has already been inserted.
I get a
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource[/quote]
on line 7 error.
From what I remember...this should be right. What's my problem? And how, once I've grabbed everything, display more than one news insert at a time? I'm thinking with maybe an array, but how would I do that?