|
Posted by Jerim79 on 12/21/06 22:58
I am trying to incorporate a random quote feature on my website. I have
a database table called random_quote with two columns. Column 1 is
MessageID and column 2 is Message. Message contains several sentences,
and MessageID contains a number. I have 5 entries in the table. Here is
the code I am using to query the database and write the quote to the
screen:
$random=rand(1,5);
$query="SELECT Message FROM random_quote WHERE MessageID=$random";
$message = mysql_query($query) or die(mysql_error());
echo $message;
But it only returns "Resource #5." I had someone mention
mysql_fetch_array, but that seems like an unecessary way to go about
it. To me, logically the code above should work. It should pull the
message from the database and assign it to $message. And then write
$message to the screen. So what's wrong with it and how can I fix it?
Navigation:
[Reply to this message]
|