In my script, I am using a ForEach to loop through all values in my $_POST array, and validate the data that was submitted.
Inside the loop, I have this line of code…
// Call Validation Function.
list($responseOK, $errors[$articleSurveyQuestionID]) = validateSurveyResponse($dbc, $articleSurveyQuestionID, $surveyResponse);
echo "<p>\\$responseOK = $responseOK, <br />\\$errors[$articleSurveyQuestionID] = $errors[$articleSurveyQuestionID]</p>";
Following this loop, I have…
if (empty($errors)){
// Valid Form Data.
echo "<p>NO ERRORS!!</p>";
}else{
echo "<p>ERRORS!!</p>";
}
And in the Function being called, I have this code sub-section…
case 'OPEN':
if (empty($surveyResponse)){
// Response does Not Exist.
return array(91, NULL);
}else{
// Response Exists.
// more stuff here...
}
break;
I know the first branch in my Case is firing, and I would expect that there is NO ENTRY in my $errors array, but on my screen I am seeing this…
$responseOK = 91,
$errors[3] =
$responseOK = 91,
$errors[7] =
$responseOK = 91,
$errors[8] =
ERRORS!!
Each of those values represents a TextArea that was left blank when the Survey was submitted.
I do NOT want anything written into my $errors array if there is an entry that is either 1.) a NULL, or 2.) Less than 1,024 Characters, because either is a valid response. However, if an entry over 1,024 characters, then it is too big, and it should throw an error so I can tell the User.
What am I doing wrong??
Thanks,
Debbie