Jump to content

Is it bad


jaymc

Recommended Posts

Is it bad to do this

[code]$name = $_GET['name'];[/code]

Taking into account that name may not always be set basically resulting in a dead variable which basically gives the following error

[b]Notice: Undefined variable: ord in /home/jaydio/public_html/search/search.php on line 275[/b]

Obviously its only a notice, but is it ok to just turn the error reporting off?
Link to comment
https://forums.phpfreaks.com/topic/24888-is-it-bad/
Share on other sites

That's fine. What's happening is that your "error_reporting" level is set too high in the php.ini file.

Change it to:

[color=blue]error_reporting  = E_ALL & ~E_NOTICE & ~E_STRICT[/color]

Additionaly, you can say:

[code]<?php

if($_GET[name] == ''){$name='';}

else {$name = $_GET[name];}

?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/24888-is-it-bad/#findComment-113436
Share on other sites

[quote author=Caesar link=topic=112486.msg456595#msg456595 date=1161651080]
That's fine. What's happening is that your "error_reporting" level is set too high in the php.ini file.

Change it to:

[color=blue]error_reporting  = E_ALL & ~E_NOTICE & ~E_STRICT[/color]

Additionaly, you can say:

[code]<?php

if($_GET[name] == ''){$name='';}

else {$name = $_GET[name];}

?>[/code]
[/quote]There is no such thing as "too high" when it comes to error_reporting. Fix your errors, do not sweep them under the carpet. It really, really peeves me to see people offering this as "advice" when it is just downright poor programming.

Just because you can't see the error message, does not mean the error does not occur.
Link to comment
https://forums.phpfreaks.com/topic/24888-is-it-bad/#findComment-113442
Share on other sites

[quote author=Jenk link=topic=112486.msg456601#msg456601 date=1161651461]There is no such thing as "too high" when it comes to error_reporting. Fix your errors, do not sweep them under the carpet. It really, really peeves me to see people offering this as "advice" when it is just downright poor programming.

Just because you can't see the error message, does not mean the error does not occur.
[/quote]

Excuse me but, here is a huge diference between Warnings/Notices...and errors. And there is a huge diference between error_reporting = 2039, and error_reporting = 2047. You can have an error free script that will return insignificant Notices when the error_reporting leel is set too low. :-/
Link to comment
https://forums.phpfreaks.com/topic/24888-is-it-bad/#findComment-114407
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.