This code works on my development setup at home, but not at work. The computers are configured the same as far as I can tell.
Here are my errors:
PHP Notice: Undefined variable: array in C:\WindProject\Webroot\functions.php on line 41
PHP Warning: array_key_exists(): The second argument should be either an array or an object in station_compare.php on line 145
PHP Warning: Invalid argument supplied for foreach() in station_compare.php on line 153
#functions.php lines 37-42
function arraymonthyearday ($result){
while ($line = mysql_fetch_array($result, MYSQL_NUM)) {
$array[$line[0].$line[1].$line[2]] = $line[3];
}#while
return $array;
}#function
#station_compare.php lines 153-159
foreach($station2 as $k => $v) {#remove key if not present in other station
if (!array_key_exists($k, $station1)) {
unset($station2[$k]);}
else{
#print "$v <br>\n";
$y[] = $v;}
}#foreach
I can remove the undefined variable error by putting $array="" before the while loop in functions.php... but I don't need to do this on the other computer, and I have the same error reporting settings in php.ini. Any ideas on how to get this foreach to work?