View Single Post
  #6 (permalink)  
Old 02-14-2008, 10:04 AM
wige's Avatar
wige wige is online now
Moderator
WebProWorld Moderator
 

Join Date: Jun 2006
Location: United States
Posts: 1,784
wige RepRank 4wige RepRank 4wige RepRank 4wige RepRank 4
Default Re: undefine variable

$errors is only created if there is an actual error. if($errors) tests if the $errors variable contains a value other than false, but if no errors were generated, $errors is never created. There are two solutions.
  1. Make the first line of the script $errors=false; This will cause the script to work, because the if condition will fail if no errors are generated.
  2. Replace the if($errors) test with if(isset($errors)) which checks if the variable exists. Since the variable currently only gets created if there is an error, if $errors has not been created the test will fail.
Note, these are two ways of accomplishing the same task. Do not do both.
__________________
The best way to learn anything, is to question everything.
Reply With Quote