Connecting Tech Pros Worldwide Forums | Help | Site Map

fetch array function

teser3@hotmail.com
Guest
 
Posts: n/a
#1: Jul 2 '08
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

JazzyJay
Guest
 
Posts: n/a
#2: Jul 2 '08

re: fetch array function


On Jul 3, 12:12*am, "tes...@hotmail.com" <tes...@hotmail.comwrote:
Quote:
For the below query:
----------
$res = mysql_query("select * from tableOne where clientID='".
$_GET['getClientId']."'") or die(mysql_error());
Firstly, you seem to be using user/url input without sanitizing it.
Quote:
* 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
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 = Array(
0 =value
firstname =value
1 =value
lastname =value
2 =value
address =value
)

Jay
teser3@hotmail.com
Guest
 
Posts: n/a
#3: Jul 3 '08

re: fetch array function


On Jul 2, 6:28*pm, JazzyJay <djrumc...@gmail.comwrote:
Quote:
On Jul 3, 12:12*am, "tes...@hotmail.com" <tes...@hotmail.comwrote:
>
Quote:
For the below query:
----------
$res = mysql_query("select * from tableOne where clientID='".
$_GET['getClientId']."'") or die(mysql_error());
>
Firstly, you seem to be using user/url input without sanitizing it.
>
Quote:
* if($inf = mysql_fetch_array($res)
-----------------
The return from this ($inf = mysql_fetch_array($res) looks like this:
$inf["firstname"]
$inf["lastname"]
$inf["address"]
>
Quote:
I assume this translates to?
>
Quote:
0 = firstname
1 = lastname
3 = 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 = Array(
*0 =value
*firstname =value
*1 =value
*lastname =value
*2 =value
*address =value
)
>
Jay
Thanks Jay!
Closed Thread