Re: [PHP] usort(): The argument should be an array

2006-02-28 Thread Robin Vickery
On 28/02/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Can anyone comment and fix this error
 
 Warning: usort(): The argument should be an array in
 /home2/wwwabcde/public_html/search/searchfuncs.php on line 300

[...]

   usort($res, cmp);

Put a print_r($res) above this line and see what the contents of $res
are. Whatever it is, it's not an array.  Probably because your mysql
result set is empty and you forgot to initialise $res before you
looped through it (assuming the junk above is the tail end of a loop).

  -robin


Re: [PHP] usort(): The argument should be an array

2006-02-28 Thread Thorsten Suckow-Homberg



$row[4];

  $res[$i]['size'] = $row[5];

  $res[$i]['weight'] = $result_array[$row[0]];

  $i++;

 }
 usort($res, cmp); 


 echo mysql_error();

 $res['maxweight'] = $maxweight;

 $res['results'] = $results;

 return $res;

/**/

}

?

 

That's not enough, we need the part that sits above and in between the 
brace where $res gets filled.

You could also put mysql_error(); above the usort-statement.
Is it possible that $res has once been the return-value of mysql_query() ?

Don't forget to var_dump() your values _before_ the error can occur.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php