Help: Simple mysql_fetch_array error...

Discussion in 'PHP' started by Skillman13, Oct 25, 2009.

  1. #1
    I've probably missed something stupid,

    But can anyone see what is wrong with this?...

    $id = urldecode( $_GET['title'] );
    $number = urldecode( $_GET['number'] );

    echo $id;
    echo "<br>";
    echo $number; (Works upto here)

    (Error...)
    $query = mysql_query('SELECT * FROM Gamepage WHERE number = $number');
    $result = mysql_query($query);
    while($row = mysql_fetch_array($result))
    {
    echo '<img src=/images/'. $row['Picture'] .' width="280" height="200" style="border-color: #000099" border="4"/>';
    }

    Thanks alot,
     
    Skillman13, Oct 25, 2009 IP
  2. dannywwww

    dannywwww Well-Known Member

    Messages:
    804
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    110
    #2
    replace:
    $query = mysql_query('SELECT * FROM Gamepage WHERE number = $number');
    $result = mysql_query($query);
    PHP:
    with...

    
    $result = mysql_query("SELECT * FROM `Gamepage` WHERE `number`  = '$number'");
    
    PHP:
     
    dannywwww, Oct 25, 2009 IP
    Skillman13 likes this.
  3. Skillman13

    Skillman13 Peon

    Messages:
    229
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Ok great it works, thanks alot :)
     
    Skillman13, Oct 25, 2009 IP
  4. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #4
    Skillman13, a small suggestion!

    Keep all your queries related to same module in single thread, that will be helpful to you when you have to look for solution of the same problem again :)
     
    mastermunj, Oct 25, 2009 IP
  5. heavydev

    heavydev Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Skillman also please make sure to sanitize that input because as you have it right now it would VERY EASY for someone to inject sql
     
    heavydev, Oct 25, 2009 IP