You are here: fetch_array() « PHP Programming Language « IT news, forums, messages
fetch_array()

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация