Click here to get back home

fetch array function

 HomeNewsGroups | Search | About
 comp.lang.php    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
fetch array function teser3@hotmail.com 07-02-2008
Posted by teser3@hotmail.com on July 2, 2008, 6:12 pm
Please log in for more thread options
For the below query:
----------
$res = mysql_query("select * from tableOne where clientID='".
$_GET['getClientId']."'") or die(mysql_error());
if($inf = mysql_fetch_array($res)
-----------------
The return from this ($inf = mysql_fetch_array($res) looks like this:
$inf["firstname"]
$inf["lastname"]
$inf["address"]

I assume this translates to?


0 = firstname
1 = lastname
3 = address

Posted by JazzyJay on July 2, 2008, 6:28 pm
Please log in for more thread options
> For the below query:
> ----------
> $res =3D mysql_query("select * from tableOne where clientID=3D'".
> $_GET['getClientId']."'") or die(mysql_error());

Firstly, you seem to be using user/url input without sanitizing it.

> =A0 if($inf =3D mysql_fetch_array($res)
> -----------------
> The return from this ($inf =3D mysql_fetch_array($res) looks like this:
> $inf["firstname"]
> $inf["lastname"]
> $inf["address"]
>
> I assume this translates to?
>
> 0 =3D firstname
> 1 =3D lastname
> 3 =3D address

mysql_fetch_array can produce zero indexed array, associated array or
both. Default is both.
So I guess in your case you'd get:

$inf =3D Array(
0 =3D> value
firstname =3D> value
1 =3D> value
lastname =3D> value
2 =3D> value
address =3D> value
)

Jay

Posted by teser3@hotmail.com on July 2, 2008, 7:36 pm
Please log in for more thread options
>
> > For the below query:
> > ----------
> > $res =3D mysql_query("select * from tableOne where clientID=3D'".
> > $_GET['getClientId']."'") or die(mysql_error());
>
> Firstly, you seem to be using user/url input without sanitizing it.
>
> > =A0 if($inf =3D mysql_fetch_array($res)
> > -----------------
> > The return from this ($inf =3D mysql_fetch_array($res) looks like this:
> > $inf["firstname"]
> > $inf["lastname"]
> > $inf["address"]
>
> > I assume this translates to?
>
> > 0 =3D firstname
> > 1 =3D lastname
> > 3 =3D address
>
> mysql_fetch_array can produce zero indexed array, associated array or
> both. Default is both.
> So I guess in your case you'd get:
>
> $inf =3D Array(
> =A00 =3D> value
> =A0firstname =3D> value
> =A01 =3D> value
> =A0lastname =3D> value
> =A02 =3D> value
> =A0address =3D> value
> )
>
> Jay

Thanks Jay!

Similar ThreadsPosted
Fetch array, display and update, all in one.. ? September 2, 2004, 1:03 pm
Fetch array, display and update, all in one.. ? September 7, 2004, 1:17 pm
How to "fetch" a certain id November 16, 2006, 9:07 pm
pop3 mail fetch with PHP August 18, 2005, 4:13 am
select on updated value during the fetch June 16, 2006, 3:52 am
IMDB fetch with PowermovieList Hangs for exact matches May 6, 2008, 9:06 am
Which array function? September 11, 2006, 3:29 am
Array function November 5, 2007, 8:24 am
returning an array from a function May 25, 2006, 6:56 am
function call as an array April 24, 2007, 8:27 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap