Help to error

Discussion in 'PHP' started by idev, Mar 2, 2011.

  1. #1
    Hello DP'ers

    i wonder if someone could help me to fix this error

    Warning: extract() [function.extract]: First argument should be an array in /home/user/domain/gift.php on line 213
    PHP:
    Lines 210 - 220
    
    or die('Could not perform search; ' . mysql_error());
    
    $row = mysql_fetch_array($result) ;
    
    extract($row);
    
    $nh=$hits;
    
    ++$hits;
    
    $query = "UPDATE hits
    
    SET hits = '$hits' ";
    
    $result = mysql_query($query)
    
    or die("Invalid query: " . mysql_error());
    
    PHP:
    Thanks
     
    idev, Mar 2, 2011 IP
  2. Mike Griffiths

    Mike Griffiths Peon

    Messages:
    57
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I'll assume the line just before the begining of your code is mysql_fetch_array. This produces a double array containing an associative array and a numeric array, which extract isn't expecting. Try changing to mysql_fetch_assoc.

    If that still doesn't work then it's probably a problem with the query itself. Although it might not be erroring, it might just be returning an empty result set. Do the following above extract:
    echo '<pre>'.print_r($row, true).'</pre>
    Code (markup):
    If you get nothing then your result set it empty, if you get a pretty array then you know that something else is a miss.
     
    Mike Griffiths, Mar 4, 2011 IP