Jump to content


Photo

Easy Question / Easy Answer


  • Please log in to reply
4 replies to this topic

#1 stevesmename

stevesmename
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 07 March 2006 - 10:06 PM

When using check boxes in forms on HTML Pages -- I send the data over to PHP and then request to pull the data from the checkbox -- BUT if the checkbox wasn't selected, then a notice displays on the screen saying variable not defined.


How do I get this notice to not display.



I know I can shut it off in php.ini settings, but I rather not do this way - I like to debug my errors.



-- Thanks for your help.

#2 mem0ri

mem0ri
  • Members
  • PipPipPip
  • Advanced Member
  • 110 posts

Posted 07 March 2006 - 10:55 PM

[!--quoteo(post=352641:date=Mar 7 2006, 02:06 PM:name=stevesmename)--][div class=\'quotetop\']QUOTE(stevesmename @ Mar 7 2006, 02:06 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
When using check boxes in forms on HTML Pages -- I send the data over to PHP and then request to pull the data from the checkbox -- BUT if the checkbox wasn't selected, then a notice displays on the screen saying variable not defined.
How do I get this notice to not display.
I know I can shut it off in php.ini settings, but I rather not do this way - I like to debug my errors.
-- Thanks for your help.
[/quote]


You can also put an @ in front of your variable...as in:

$info = @$_POST['checkbox2'];

#3 txmedic03

txmedic03
  • Members
  • PipPipPip
  • Advanced Member
  • 313 posts
  • LocationCall, TX, USA

Posted 08 March 2006 - 07:25 AM

Well, I would really need to see the form and know exactly what you want to do with the form before I could make a good suggestion. I don't like to just hide errors when they occur, I like to prevent them from ever occuring. One method would be to use if ( isset($_POST['checkbox1']) ) { }. If that checkbox is checked then do whatever it is you wanted to do with it. If the script can be processed dynamically then I may have a few more tricks up my sleeve you may be interested in. Please, give some more details on the script and the form and I will try to assist you further.

SEMPER FIDELIS!

I can't stop you from doing something silly, but at least I can help you do it right.


#4 stevesmename

stevesmename
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 08 March 2006 - 02:31 PM

The @ Symbol worked perfectly.


Thanks for both of your help.

#5 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 08 March 2006 - 03:09 PM

Do not use the "@" when trying to debug your code. It suppresses error message. I almost always use the "if (!isset($var))" method.

Ken




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users