Training, Open Source computer languages

PerlPHPPythonMySQLhttpd / TomcatTclRubyJavaC and C++LinuxCSS

Search our site for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Easy handling of errors in PHP
How often have you written a piece of code that's a "spike solution" - it works well on good data - and then spent just as long as you took to do most of the work in fixing errors? I know I have!

These days, I plan my error strategy from minute 0 of hour 0 of day 0. "How to handle errors" is a critical part of application design and ... here's how I do a lot of it in PHP.

a) Set a variable (e.g. $error) to 0 at the start of the code.

b) Whenever an error is found, $error++ and perhaps add a message to $errstr, both of which are global variables declared in all functions that can throw an exception.

c) When the analysis logic is completed, decide whether to display the next screen or recycle the current one with a simple if ($error) test.

Gone are the days of ....
if ($_POST[month] < 1 or $_POST[month] > 12 or $_POST[day] < 1 or $_POST[day] > 31 or (not eregi( '^[A-Z]{1,2}[0-9]{1,2}[[:space:]]+' ,$_POST[postcode])) or (not ereg( '[[:digit:]]{4}', $_POST[phone])) or (not ereg('@',$_POST[email)) or $startdate < time() ....
.... Thank Goodness!

(written 2007-08-27 18:49:13)

 
Associated topics are indexed under
H115 - Designing PHP-Based Solutions: Best Practice
H117 - Security in PHP

Back to
Flash - is it available to your web page?
Previous and next
or
Horse's mouth home
Forward to
Well House Manor appoints a General Manager

Some other Articles
Tktable - Laying out data in a matrix - Tcl/Tk
GUI design - Sketch it out first! (Java / Swing example)
Java - Client side applet applications as well as server side
Well House Manor appoints a General Manager
Easy handling of errors in PHP
Flash - is it available to your web page?
Resetting session based tests in PHP
Perl for Larger Projects - Object Oriented Perl
Customer feedback - lifeblood of a business
Well House Manor - feature comparison against the old place!
1638 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

© WELL HOUSE CONSULTANTS LTD., 2008: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho