When the user performs an action that causes an error I dont want to just echo the error message as it happens in the code.
I came up with a simple function that would process my errors and wrap them with a paragraph and relevant css class. Unfortunatly it seems that I am only able to then display all these errors at the bottom of the page (end of the script) then position them using CSS where I want them using CSS positioning (yuck!).
I am not happy with this way of processing my errors and after putting in a couple of hours work on it last night am starting to get annoyed trying to think of another way to do it.
This is a really simplified version of what ive been doing (from memory, bere with me).
<?php
function errorStack($error,$type = '1'){
if($type == '1'){
$msg = '<p class="error">' . $error . '</p>';
}else{
$msg = '<p class="info">' . $error . '</p>';
}
return $msg;
}
$myerror = 'Oops! Sorry there seems to have been an error.';
$stack .= errorStack($myerror);
?>
//end of all PHP code. <div id="errorstack"> <?php echo $stack; ?> </div> </body> </html>
I am sure I have overlooked somthing.
- How do you process your errors for display to the user?
- Standard form validation errors are fine for now since they echo above or next to the form field in question.
- Is putting all the errors into a function to be processed overkill in your opinion?
- Am I over complicating the thought process?
Thanks guys

New Topic/Question
Reply




MultiQuote




|