2

I know that in general the php errors can be suppressed using error_reporting(0) or the '@'. I have many sql queries being fired in a certain section of my work, I wanted to know that does adding error_reporting(0) suppress the appearance of errors arising from mysql queries?

I read online varying answers. Some state it will help while others say it wont work like that .

5

2 Answers 2

8

Try putting this at the top of your code:

ini_set("display_errors", "off");

And yes, adding @ at the beginning of functions etc, for example:

$query = @mysql_query("text..");

Should suppress errors.

3
  • 1
    error_reporting(0) at the start of the script wont do the trick ? Feb 1, 2013 at 10:37
  • 1
    and please explain how setting display_errors will be better than error_reporting. Thank you Feb 1, 2013 at 10:39
  • 1
    @BhumiSinghal Several times I've tried error_reporting(0); and some errors still show up. Often I've been able to overcome this by also putting ini_set("display_errors", "off"); at the top of my code. Just try it and see if it works for you. Feb 1, 2013 at 10:42
0

If you have htaccess file then you can controll all errors by this. try this

1
  • I do have an htaccess but I am looking for the simplest possible solution ...and I guess php surely provides something to handle this :) Feb 1, 2013 at 12:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.