View Single Post
Old 02-09-2013, 01:32 PM   PM User | #5
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,658
Thanks: 45
Thanked 456 Times in 444 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
Quote:
Originally Posted by countrydj View Post
If I set this code at the very top, I get all sorts of errors because nothing has been set:

So I move the error reporting further down:

I only get 1 error:
If its at the top, you are turning on error reporting for the whole script. That means that ANY error will be output. If you turn it on half way down the script it will only output errors from that bit of code and below. It will not output errors on code above it. Thats how code works - top to bottom and never backwards.

As for the m problem, to test it against "" you are assuming that $_GET['m'] already exists. It may not and so by trying $_GET['m'] != "" your code will output an error or notice because $_GET['m'] doesn't actually exist to even test.

To deal with that you use the isset() function. This literally determines if $_GET['m'] "is set" - in other words was actually sent by the browser - like this:

PHP Code:
if ((isset($_GET['m'])) and ($_GET['m'] != '')) 
If it is not set, the if conditional will return false and will output no error or run that piece of code.

This concept can be a bit confusing initially but basically if the browser doesn't send it, then to PHP it doesn't exist. It's a bit like me saying to you, use http.exe to debug your ouput. You've no idea what http.exe is because its my own program that I use. IfI sent it to you by email, you would know what it is and so http.exe "is set" in your mind and it now exists. If I don't send it to you then you've no idea what it is, what it does, how to use it etc and in reality as far as you're concerned it doesn't exist.
__________________
Please don't be rude: Put your php code in [php][/php] tags. It is a sticky topic at the top of the forum and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.

Last edited by tangoforce; 02-09-2013 at 01:36 PM..
tangoforce is offline   Reply With Quote
Users who have thanked tangoforce for this post:
countrydj (02-09-2013)