[PHP] error suppresion
I have a form, the action is PHP_SELF. When the form is submitted it prints the info lower on the page. The problem, the errors for the empty fields are printed until the form is submitted. What would be the best way of suppressing these error? TIA Gary -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] error suppresion
I have a form, the action is PHP_SELF. When the form is submitted it prints the info lower on the page. The problem, the errors for the empty fields are printed until the form is submitted. What would be the best way of suppressing these error? The best way to suppress your errors is to fix them. :) Or you can work around it by using the error_reporting() function. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] error suppresion
John W. Holmes wrote: I have a form, the action is PHP_SELF. When the form is submitted it prints the info lower on the page. The problem, the errors for the empty fields are printed until the form is submitted. What would be the best way of suppressing these error? The best way to suppress your errors is to fix them. :) Or you can work around it by using the error_reporting() function. ---John Holmes... They are not really errors they are reporting that the form fields are empty until the form is submitted. Notice: Undefined index: Gary -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] error suppresion
Just reduce the error_reporting() level while you display the form, then. Set it so it does not show NOTICES. ---John Holmes... -Original Message- From: Gary [mailto:[EMAIL PROTECTED]] Sent: Sunday, September 29, 2002 2:29 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] error suppresion John W. Holmes wrote: I have a form, the action is PHP_SELF. When the form is submitted it prints the info lower on the page. The problem, the errors for the empty fields are printed until the form is submitted. What would be the best way of suppressing these error? The best way to suppress your errors is to fix them. :) Or you can work around it by using the error_reporting() function. ---John Holmes... They are not really errors they are reporting that the form fields are empty until the form is submitted. Notice: Undefined index: Gary -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] error suppresion
Gary wrote: They are not really errors they are reporting that the form fields are empty until the form is submitted. Notice: Undefined index: That means your code is not doing any checking of the incoming data. You should always check that the data coming is what you expect it to be. It's good programming practice and helps security. Just add the following to your code and every thing will be fine (assuming POST, but works with GET or any other): if (isset($_POST[myvar name])) { $value = $_POST[myvar name]; } else { $value = ; } I always turn error reporting way up when coding and debugging, it helps me to find places where I have undefined variables when the variables really *should* be defined ... meaning I have a bug ;) Jc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] error suppresion
Jean-Christian Imbeault wrote: Gary wrote: They are not really errors they are reporting that the form fields are empty until the form is submitted. Notice: Undefined index: That means your code is not doing any checking of the incoming data. You should always check that the data coming is what you expect it to be. It's good programming practice and helps security. Just add the following to your code and every thing will be fine (assuming POST, but works with GET or any other): if (isset($_POST[myvar name])) { $value = $_POST[myvar name]; } else { $value = ; } The problem is the vars will never be set until the form is submitted. The e-notice's are for the empty form elements before the form submission. So the else value would be, turn off error reporting until submission. Gary -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php