Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 2nd, 2008, 11: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, 11: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 3rd, 2008, 12:45 AM
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


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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 network members.
Post your question now . . .
It's fast and it's free

Popular Articles