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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.