t4newman Posted March 22, 2010 Share Posted March 22, 2010 I'm checking to see if two values from a form are not null - I've tried several variations but no joy... if ($var1 != "" AND $var2 != "") { do this } else { do this } Link to comment https://forums.phpfreaks.com/topic/196141-checking-two-parameters-in-an-if-statement/ Share on other sites More sharing options...
nizuya Posted March 22, 2010 Share Posted March 22, 2010 if (($var1 != "") && ($var2 != "")) { } Link to comment https://forums.phpfreaks.com/topic/196141-checking-two-parameters-in-an-if-statement/#findComment-1030047 Share on other sites More sharing options...
nizuya Posted March 22, 2010 Share Posted March 22, 2010 or this might be better: if (!is_null($var1) && !is_null($var2)) { Check out this site for info on php Operators: http://www.w3schools.com/php/php_operators.asp Also, rather than using $var = "" for null you should use $var = NULL. Link to comment https://forums.phpfreaks.com/topic/196141-checking-two-parameters-in-an-if-statement/#findComment-1030050 Share on other sites More sharing options...
t4newman Posted March 22, 2010 Author Share Posted March 22, 2010 What about <not equal to> NULL? Link to comment https://forums.phpfreaks.com/topic/196141-checking-two-parameters-in-an-if-statement/#findComment-1030058 Share on other sites More sharing options...
wildteen88 Posted March 22, 2010 Share Posted March 22, 2010 What about <not equal to> NULL? is_null is the same as $var != NULL Link to comment https://forums.phpfreaks.com/topic/196141-checking-two-parameters-in-an-if-statement/#findComment-1030072 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.