The Little Guy Posted October 31, 2008 Share Posted October 31, 2008 It goes into the else on where it says if($cat != 0) and $cat is equal to Music when I echo it out. I can't see what I am doing wrong (it is the 3rd if statement).... $title = strip_tags($_POST['title']); $description = strip_tags($_POST['description'],'<a>'); $cat = $_POST['category']; $vidExt = $_POST['videoType']; $good = FALSE; if(strlen($title) > 3){ if(strlen($description) > 19){ if($cat != 0){ if(in_array($vidExt,$fileTypes)){ $good = TRUE; }else{ $good = FALSE; $r = 'fType'; } }else{ $good = FALSE; $r = $cat; } }else{ $good = FALSE; $r = 'descript'; } }else{ $good = FALSE; $r = 'title'; } echo $r; Link to comment https://forums.phpfreaks.com/topic/130811-ifelse-problems/ Share on other sites More sharing options...
n3ightjay Posted October 31, 2008 Share Posted October 31, 2008 You 3rd if is comparing incomparable types (I don't know if thats the actuall definition of the solution but this works i tested it) ??? if you change it to if($cat != ""){ or if($cat != "0"){ it will work Link to comment https://forums.phpfreaks.com/topic/130811-ifelse-problems/#findComment-679012 Share on other sites More sharing options...
n3ightjay Posted October 31, 2008 Share Posted October 31, 2008 oh oh oh ... or if(strlen($cat) != 0){ Link to comment https://forums.phpfreaks.com/topic/130811-ifelse-problems/#findComment-679014 Share on other sites More sharing options...
The Little Guy Posted October 31, 2008 Author Share Posted October 31, 2008 0 is one of the possible values passed through... But... I am giving $cat != "0" a try Link to comment https://forums.phpfreaks.com/topic/130811-ifelse-problems/#findComment-679022 Share on other sites More sharing options...
DarkWater Posted October 31, 2008 Share Posted October 31, 2008 How about: if (!empty($cat)) { } Link to comment https://forums.phpfreaks.com/topic/130811-ifelse-problems/#findComment-679024 Share on other sites More sharing options...
n3ightjay Posted October 31, 2008 Share Posted October 31, 2008 damn ... im sure theres a million more .... technically this qualifies as well if(isset($cat)){ Link to comment https://forums.phpfreaks.com/topic/130811-ifelse-problems/#findComment-679030 Share on other sites More sharing options...
DarkWater Posted October 31, 2008 Share Posted October 31, 2008 isset() is not the same as !empty(). Since he has $cat = $_POST['category';, it'll be set no matter what. Example: <?php $foo = ''; var_dump(isset($foo)); Outputs: bool(true) Link to comment https://forums.phpfreaks.com/topic/130811-ifelse-problems/#findComment-679033 Share on other sites More sharing options...
The Little Guy Posted October 31, 2008 Author Share Posted October 31, 2008 putting quotes around the zero worked I now can't get the last if statement to work I realized that the variable for the second value in the in_array function was spelled wrong, so I fixed it. ill see what value is being passed to it. Link to comment https://forums.phpfreaks.com/topic/130811-ifelse-problems/#findComment-679036 Share on other sites More sharing options...
n3ightjay Posted October 31, 2008 Share Posted October 31, 2008 isset() is not the same as !empty(). Since he has $cat = $_POST['category';, it'll be set no matter what. Example: <?php $foo = ''; var_dump(isset($foo)); Outputs: bool(true) Good point got excited in trying to find multiple ways of answer the same question... assumed checking against zero was checking if it was empty ... therefore leading me down the path to isset() Link to comment https://forums.phpfreaks.com/topic/130811-ifelse-problems/#findComment-679048 Share on other sites More sharing options...
redarrow Posted October 31, 2008 Share Posted October 31, 2008 use a switch ........... Link to comment https://forums.phpfreaks.com/topic/130811-ifelse-problems/#findComment-679092 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.