PhP Undefined Variable?-Collection of common programming errors
- wow ok lemme shorten this up for you and then you can move on. It would be wise to switc(){} this out but you can do this too and make sure $EmailFrom etc is from $_POST[] or $_GET[] if that doesn’t work then look at your for and make sure it has etc $validationOK=true; if (trim($EmailFrom)==””) $validationOK=false; if (trim($FirstName)==””) $validationOK=false; if (trim($TelNo)==””) $validationOK=false; if (!is_numeric($TelNo)) $validationOK=false; if (!$validationOK) { print “”; exit; } would == $validationOK = (trim($EmailFrom) == “”) || (trim($FirstName) == “”) || (trim($TelNo) == “”) || (!is_numeric($TelNo))) ? 0 : 1; if(!$validationOK){ echo “”; exit;
}
- Hello, If you are having a problem with warnings showing that you have Undefined Variables you can use the isset() function. $validationOK=true; if (trim(isset($EmailFrom))==””) $validationOK=false; …
Stephen Williamson, Server Engineer, http://www.HostMySite.com?utm_source=bb
Originally posted 2013-11-09 22:44:41.