The flaw in your current error system is a bit obvious, results.php
doesn't even check that it's receiving an error. Heck, it doesn't seem to be checking very much at all, it just constructs everything and sends away. The only thing I see being checked is if the error has been logged in the database, which it is trying to log regardless of what has happened. This is probably the most inefficient script in existence.
Adding on top of that, you seem to be wanting to send an email on "errors" such as when somebody enters your index without a GET request for a "section". Why on earth would you want an email for that?? The redirect and notice is the most you can do in practical terms. You're basically spamming yourself; knowing afterwards that someone took away the GET is pointless, as is logging it.
If you're just concerned with a temporary fix, then you need to add checks around the error logging and email sending for something that is ONLY sent from resulting errors. In reality this needs a restructure with different logic entirely, such as what the others have suggested. You might want to also create your code a great deal more compartmentalized in v.3. If you create your code efficiently, then editing sections or making changes like these becomes a 5 minute hassle.
@ Fou-Lu : Because
uses actual PHP error levels, will it also populate the native error log? That could sure be useful.