Page 1 of 1

array error

Posted: Fri Jun 20, 2008 12:39 pm
by freeAngel_007
Hi all,

I have this strange error on php server.
Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/clients/look4place.com/look4place.com/dev/includes/classes/GUI.class/GUI.class.php on line 1228
and my code is

Code: Select all

 
        $query = "SELECT city FROM orders WHERE city != \"\"";
 
        $row = $this->CallQuery($query);
 
        $temp_Var = array();
        $counter = 0;           
        foreach ($row as $value){
            if(!empty($value))
            {
                if(!in_array($temp_Var, $value))
                {
                    $temp_Var[$counter] = $value;
                    $counter++;
                }
            }
        }
        
        print_r($temp_Var);
        exit;
 
any Idea what can be the problem?
It in_array function works well in other scripts.

Thx. for reply...

Re: array error

Posted: Fri Jun 20, 2008 1:02 pm
by nowaydown1
Basically what that is telling you is that $value is not an array. So try to find out what $value is at that point in the code where it bombs.

Re: array error

Posted: Fri Jun 20, 2008 1:04 pm
by phice
Change line 11 from

Code: Select all

if(!in_array($temp_Var, $value))
to

Code: Select all

if(!in_array($value,$temp_Var))
If you notice on http://php.net/in_array, the structure of the function is in_array(needle, haystack), not in_array(haystack,needle).

Re: array error

Posted: Fri Jun 20, 2008 1:17 pm
by freeAngel_007
many thanks phice it works now...