Connecting Tech Pros Worldwide Help | Site Map

fetch array function

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 2nd, 2008, 10:15 PM
teser3@hotmail.com
Guest
 
Posts: n/a
Default fetch array function

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, 10:35 PM
JazzyJay
Guest
 
Posts: n/a
Default 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 2nd, 2008, 11:45 PM
teser3@hotmail.com
Guest
 
Posts: n/a
Default 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!
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.