Here is the code thats giving me problems:
Code: Select all
if(!isset($_POST[$fieldname]) || (empty($_POST[$fieldname]) && $_POST[$fieldname] != 0)){
$errors[] = $fieldname;
}Moderator: General Moderators
Code: Select all
if(!isset($_POST[$fieldname]) || (empty($_POST[$fieldname]) && $_POST[$fieldname] != 0)){
$errors[] = $fieldname;
}Code: Select all
empty($_POST[$fieldname]) && $_POST[$fieldname] != 0Code: Select all
empty($_POST[$fieldname]) && !empty($_POST[$fieldname])Thank you! It worked when I used "0".kaszu wrote:Checking any value against 0 with != is useless since it will evaluate to true only if value will be 0, false, empty or null, which in this case will be duplication of what empty() function does (almost). So basicallyis almost the same asCode: Select all
empty($_POST[$fieldname]) && $_POST[$fieldname] != 0So it never evaluates to true and is useless, so only part of condition which ma yevaluate to true is isset(...)Code: Select all
empty($_POST[$fieldname]) && !empty($_POST[$fieldname])
$_POST value is always a string or null (not defined), so maybe instead of '!= 0' you mean '!= "0"' ?
In that case condition will make sense. If it's not the case please explain why != 0 is needed.