array error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
freeAngel_007
Forum Newbie
Posts: 9
Joined: Thu Jun 19, 2008 12:23 pm

array error

Post 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...
nowaydown1
Forum Contributor
Posts: 169
Joined: Sun Apr 27, 2008 1:22 am

Re: array error

Post 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.
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Re: array error

Post 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).
Image Image
freeAngel_007
Forum Newbie
Posts: 9
Joined: Thu Jun 19, 2008 12:23 pm

Re: array error

Post by freeAngel_007 »

many thanks phice it works now...
Post Reply