RE: Re: Invalid argument supplied for foreach()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Something that I use to make sure I don't give the user a nicer error

If ( is_array( $array ) )
{
	foreach ( $array as $key => $value )
	{
		echo 
	}
}
Else
{
	exit('Expecting array')
} 

-----Original Message-----
From: David Robley [mailto:robleyd@xxxxxxxxxxxxxx] 
Sent: Monday, December 19, 2005 5:21 PM
To: php-general@xxxxxxxxxxxxx
Subject:  Re: Invalid argument supplied for foreach()

Jose Borquez wrote:

> I am getting the following errors when accessing a php page:
> 
> /usr/local/www/groupoffice-com-2.14-FINAL-4/configuration/index.php(29
> 9)
> : Warni
> ng - Invalid argument supplied for foreach() [Mon Dec 19 15:10:52 
> 2005] [error] PHP Warning:  Invalid argument supplied for f
> oreach() in
> /usr/local/www/groupoffice-com-2.14-FINAL-4/configuration/index.php
> on line 299
> 
> I solved previous php error problem by installing the php5-extensions, 
> but now I am getting the following errors in my log files and I have 
> no idea what it could be.  Any help would be greatly appreciated.
> 
> Thanks in advance,
> Jose

foreach expects to have an array passed as its argument; the error message
suggests that what it is receiving is not an array. Without seeing your
code, the only suggestion we could make (well, me anyway) is to check what
is actually being passed, with print_r or var_dump.



Cheers
--
David Robley

Support bacteria - it's the only culture some people have!

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

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux