Re: Can't get results from MySQL via PHP
| From: | Alp | Date: | Mon, 15 Nov 2004 10:37:48 +0000 |
| Subject: | Re: Can't get results from MySQL via PHP | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-202030@lists.php.net to get a copy of this message | ||
Thanks for your response, I did finally sove it by changing
mysql_fetch_row($result); to
mysql_fetch_array($result);
and assigning my variable as $somevar = $list['fieldname'];
Now I get my real value. Thanks again.
Alp
"Raditha Dissanayake" <jabber@raditha.com> wrote in message
news:4198792D.9030507@raditha.com...
> Alp wrote:
>
> >Hi there,
> >
> >I've been fighting with PHP/MySQL to get proper results but without
success.
> >For example:
> > $sql = "SELECT * FROM prod WHERE shortname='Myprog";
> > $result = mysql_query($sql); >>> returns Resource #7
> > $list = mysql_fetch_row($result); >>> returns Array
> >
> >and actually the data in the table is a four digit number! The query
returns
> >what is expected in MySQL but refuses to do so under php. What is it (or
> >could be) that I am doing wrong/missing?
> >
> >
> PHP is behaving exactly as it should. The fact that your table has one
> column only is of no relevence you still have to retrieve the first
> element of the array that is returned mysql_fetch_row($result);
>
> --
> Raditha Dissanayake.
> ------------------------------------------------------------------
> http://www.radinks.com/print/card-designer/ | Card Designer
> Applet
> http://www.radinks.com/upload/ | Drag and Drop
> Upload