Jump to content

if/else problems


The Little Guy

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.