mySQL mysql_fetch_array() error

Discussion in 'MySQL' started by cammy_dude, Nov 29, 2007.

  1. #1
    Hi, I have wrote a script to display pictures. The Picture information is in a table in a mysql database called 'pictures'. I am getting the error:

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\viewpictures.php on line 18

    Line 18 is marked below. I have checked my code for errors, but I cannot seem to find any. So, can anybody else find something that I can't??

    btw, the line commented out is meant to be.

    
    <?php
    include('header.php');
    require('connect.php');
    
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
    $id = $_GET['id'];
    
    mysql_select_db($db, $con);
    
    $result = mysql_query("SELECT * FROM pictures WHERE PictureID=$id");
    
    while($row = mysql_fetch_array($result, MYSQL_ASSOC))
      {
    echo '<img src="images/' . $row[PictureID] . $row[PictureType] . '></img>';
    
    //mysql_query("UPDATE pictures SET PictureTimesViewed=$row[PictureTimesViewed]+1 WHERE PictureID=$id");
    }
    
    mysql_close($con);
    
    ?>
    Code (markup):
     
    cammy_dude, Nov 29, 2007 IP
  2. cammy_dude

    cammy_dude Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Actually, I sorted it.

    Thanks to anyone who replied
     
    cammy_dude, Nov 29, 2007 IP
  3. guruhowto

    guruhowto Guest

    Messages:
    75
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    There were actually no one :D but it might be very useful to post the fix here to keep it as an archive for others who might still be fixing the same thing. :)
     
    guruhowto, Nov 29, 2007 IP