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

Posted by Andy Hassall on 12/21/06 23:17

On 21 Dec 2006 14:58:23 -0800, "Jerim79" <mylek@hotmail.com> wrote:

>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,

Yes.

> 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.

No.

>So what's wrong with it and how can I fix it?

You've posted your own answer.

--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

 

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

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