SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can someone tell my why this simple statement don't work?

    $query = "SELECT " . $_GET['CT1'] . " FROM cbr_lookup_pricefactor_serpentine WHERE Depth = '" . $_GET['Depth'] . "'";
    $result = mysql_query($query, $conn);
    $numrows = mysql_num_rows($result);
    $row = mysql_fetch_assoc($result);
    $sqinfactor = $row[0];


    the last line does not work.
    but if i do
    $sqinfactor = $row[$_GET['CT1']];

    it does. Can someone tell me why using the value 0 (first index of the array) doesn't work?

  2. #2
    SitePoint Zealot the DtTvB's Avatar
    Join Date
    Jul 2006
    Location
    Thailand
    Posts
    162
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Because you used `mysql_fetch_assoc`.
    It will return the associated array,
    that means you cannot use 0, 1, 2, 3, and so on.

    If you want to use it, you should use mysql_fetch_array instead.

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    god thanks. I guess i was having a brain fart. I can use mysql_fetch_row also right?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •