-1

I have a problem with mysql_fetch_object in the code below. Please help me to fix.

$query .= 'order by ts_uploaded DESC' ;

$result = mysql_query($query);


// format the return data, allows us to create key for thumbname
$items = array();
while ($row = mysql_fetch_object($result)) {
    $items[$row->id]['id']          = $row->id;
    $items[$row->id]['filename']    = $row->filename;
    $items[$row->id]['status']      = $row->status;
    $items[$row->id]['format']      = $row->format;
    $items[$row->id]['title']       = $row->title;
    $items[$row->id]['duration']    = $row->duration;
    $items[$row->id]['thumbnail']   = getThumbname($row->filename);
    $items[$row->id]['width']       = $row->width;
    $items[$row->id]['height']      = $row->height;
}

return $items;

}

iavr
  • 7,547
  • 1
  • 18
  • 53
  • 2
    You are using [an **obsolete** database API](http://stackoverflow.com/q/12859942/19068) and should use a [modern replacement](http://php.net/manual/en/mysqlinfo.api.choosing.php) – Quentin Mar 21 '14 at 09:28
  • 1
    Did you try any debugging? Have a look what's inside `$result`? Checked [for an error](http://ca2.php.net/mysql_error)? – Carsten Mar 21 '14 at 09:31
  • Please post your full $query – Corbin Spicer Mar 21 '14 at 09:37

2 Answers2

0

You have an error in your mysql query. Try doing an:

echo $query;
echo mysql_error(); 

after the mysql_query statement and see what is wrong.

Veda
  • 2,025
  • 1
  • 18
  • 34
0

The warning means that mysql_fetch_object() do not have a valid result set in argument so mysql_query() is not returning it

Check your sql which was passed to mysql_query(), it is not given here.

Please note this also from php.net:

mysql extension Warning:

This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide and related FAQ for more information. Alternatives to this function include:

Bhavin Toliya
  • 31
  • 1
  • 9