PDA

View Full Version : Warning: .... foreach()


isto
12-22-2003, 08:11 AM
I get this error when I visit the link "response time by hour" in the admin menue.

Warning: Invalid argument supplied for foreach() in /var/www/web25/html/navigation/phpdig/admin/robot_functions.php on line 1364


anybody an idea what to do?

Charter
12-23-2003, 05:20 AM
Hi. What OS and version of PhpDig are you running?

isto
12-23-2003, 11:02 AM
PhpDig Version 1.6.5
PHP Version 4.3.2
MySql Version 3.23.49
Apache 1.3.26 (Unix)
Server Protocol HTTP/1.1
System Linux
Server API Apache

Charter
12-23-2003, 04:03 PM
Hi. It looks like the following query is returning zero results. When that happens $result is not an array so foreach() throws a warning. As soon as the query returns greater than zero results, the warning should go away. Thanks for pointing it out. It's something to tweak in a future release.

$query = 'SELECT DATE_FORMAT(l_ts,\\'%H:00\\') as hour,
round(avg(l_time),2) as avg_time,
count(l_id) as num_queries
FROM '.PHPDIG_DB_PREFIX.'logs
WHERE l_time > 0
GROUP BY hour';
$result = phpdigMySelect($id_connect,$query);