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; Quote Link to comment 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 Quote Link to comment 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){ Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
DarkWater Posted October 31, 2008 Share Posted October 31, 2008 How about: if (!empty($cat)) { } Quote Link to comment 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)){ Quote Link to comment 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) Quote Link to comment 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. Quote Link to comment 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() Quote Link to comment Share on other sites More sharing options...
redarrow Posted October 31, 2008 Share Posted October 31, 2008 use a switch ........... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.