fetch array function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • teser3@hotmail.com

    fetch array function

    For the below query:
    ----------
    $res = mysql_query("se lect * from tableOne where clientID='".
    $_GET['getClientId']."'") or die(mysql_error ());
    if($inf = mysql_fetch_arr ay($res)
    -----------------
    The return from this ($inf = mysql_fetch_arr ay($res) looks like this:
    $inf["firstname"]
    $inf["lastname"]
    $inf["address"]

    I assume this translates to?


    0 = firstname
    1 = lastname
    3 = address
  • JazzyJay

    #2
    Re: fetch array function

    On Jul 3, 12:12 am, "tes...@hotmail .com" <tes...@hotmail .comwrote:
    For the below query:
    ----------
    $res = mysql_query("se lect * from tableOne where clientID='".
    $_GET['getClientId']."'") or die(mysql_error ());
    Firstly, you seem to be using user/url input without sanitizing it.
      if($inf = mysql_fetch_arr ay($res)
    -----------------
    The return from this ($inf = mysql_fetch_arr ay($res) looks like this:
    $inf["firstname"]
    $inf["lastname"]
    $inf["address"]
    >
    I assume this translates to?
    >
    0 = firstname
    1 = lastname
    3 = address
    mysql_fetch_arr ay 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

    Comment

    • teser3@hotmail.com

      #3
      Re: fetch array function

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

      Comment

      Working...