Page 1 of 1

Wrong datatype error

Posted: Fri Mar 26, 2010 9:21 am
by allasso
with this command...

if (array_search($item, $items_ordered_array) === FALSE) do something ;

I get this error:

Warning: array_search() [function.array-search]: Wrong datatype for second argument...

I have read the man page for array_search several times and I don't understand why this won't work. It even tells you to use ===.

Anyone know what is happening, and what to do to make it work?

BTW, it works okay on my test server which has PHP 5.2.4, but not on the internet server I am using which has PHP 5.2.13.. ??????

thanks, Allasso

Re: Wrong datatype error

Posted: Fri Mar 26, 2010 9:31 am
by Alkis
By what I can understand from the error, it tells you that the second argument passed to array_search, in this case the $items_ordered_array, it is not an array.

The reason you get this warning on the production server and not on the test server, is maybe the production server is configured to display warnings, while the configuration on your test server is to hide them.

I suggest setting error_reporting on your php.ini to E_ALL | E_STRICT or only E_ALL is the recommended way to find those warning on the test server before uploading to your production server.

Re: Wrong datatype error

Posted: Fri Mar 26, 2010 9:32 am
by s.dot
do print_r($items_ordered_array); and see what it is
Basically the error is complaining that $items_order_array is not an array

Re: Wrong datatype error

Posted: Fri Mar 26, 2010 12:38 pm
by allasso
yes, I testing before the array was initialized.

many thanks.