$query = "SELECT COUNT(t.id), SUM(t.num_replies) FROM threads AS t WHERE t.forum_id=$forum_id";
$result = mysql_query($query);
list($num_threads, $num_posts) = mysql_fetch_assoc($result);
Equals:
Notice: Undefined offset: 1 in C:\wamp\www\includes\functions.php on line 11
Notice: Undefined offset: 0 in C:\wamp\www\includes\functions.php on line 11
Any ideas how i can get rid of these notices?
http://php.net/mysql_fetch_assoc
http://php.net/manual/en/function.list.php
You can’t assign to variables via
listfrom an associative array. Either usemysql_fetch_rowor, usually better, just use$row = mysql_fetch_assoc($result)and work with$rowas an array. You don’t really want to use_fetch_row, since then the sanity of your application hinges on the order the parameters are in in your query, which is something that can break all too easily.