You are missing operator precedence. ! is higher precedence than == so your statement effectively becomes:
if ( (!$key) == $info_keys[0]) which makes no sense. Normally you would write that code as: if ( $key != $info_keys[0] ) -Rasmus On Thu, 15 Aug 2002, Alexander Ross wrote: > what am i missing here?? I have a simple if statement that wont do whats > inside it even when true. > > this works: > > echo $key==$info_keys[0]; // returns 1 or 0 correctly > if($key==$info_keys[0]) > $query = $query; > else $query = $query." and "; > $query = $query.$key."='".$val."'"; > > this doesn't: > // the "$query = $query." and ";" just doesn't get executed .. nor does any > other statment I put inside the if statement > > echo $key==$info_keys[0]; // returns 1 or 0 correctly > if(!$key==$info_keys[0])// if it isn't the first item in the array > $query = $query." and "; > $query = $query.$key."='".$val."'"; > > > > -- > 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