tmallen Posted October 7, 2008 Share Posted October 7, 2008 How can I add a a row for every error? I know I did this before, but lost the code. The reason that this is necessary: I want errors to build into a table which is positioned absolutely (bottom: 1em; left: 1em). I can only have one copy of the table, otherwise errors overlap each other. What I have now doesn't work, and I'm not entirely sure why (I know it's crappy code, but error handling is a black box indeed, plus this is for a prototype CSS framework, so I'm not being picky): <?php $errors = "<table class='phpError'>" . "<tr><th>Level</th><th>Error</th><th>File</th><th>Line</th></tr>"; $errorCount = 0; function golondrinaErrors($number, $string, $file, $line) { global $errors; global $errorCount; $errorCount++; $errors .= "<tr><td>" . $number . "</td>" . "<td>" . $string . "</td>" . "<td>" . $file . "</td>" . "<td>" . $line . "</td>" . "</tr>"; return true; } if($errorCount > 0) { $errors .= "</table>"; echo $errors; } set_error_handler('golondrinaErrors'); Quote Link to comment Share on other sites More sharing options...
tmallen Posted October 7, 2008 Author Share Posted October 7, 2008 Er, pretty please? I can't find anything on this (which may be why nobody's answered it so far...), or on providing a wrapper element for error messages. Quote Link to comment Share on other sites More sharing options...
tmallen Posted October 8, 2008 Author Share Posted October 8, 2008 Any ideas? Don't worry, this is the last time I'll bump this post...I guess that I should head to comp.lang.php next time I have something tough to solve. Quote Link to comment Share on other sites More sharing options...
tmallen Posted October 8, 2008 Author Share Posted October 8, 2008 For anyone who comes across this, the answer was to put the echo statement at the bottom of the page (or include tree) so that it displays errors. Seems obvious now. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.