Connecting Tech Pros Worldwide Help | Site Map

fetch array function

  #1  
Old July 2nd, 2008, 11:15 PM
teser3@hotmail.com
Guest
 
Posts: n/a
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
  #2  
Old July 2nd, 2008, 11:35 PM
JazzyJay
Guest
 
Posts: n/a

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
  #3  
Old July 3rd, 2008, 12:45 AM
teser3@hotmail.com
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fetch array values yasmine answers 1 April 4th, 2008 02:21 PM
How to Convert resource as array of array ? dgs answers 1 November 5th, 2007 11:45 AM
An extra last empty field in an 'mysql_fetch_array' result array? Marcel Brekelmans answers 4 October 14th, 2005 03:35 PM
if fetch array is empty ? Sylvie Stone answers 2 July 17th, 2005 01:05 AM