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 .

Bhumi Singhal
  • 8,063
  • 10
  • 50
  • 76

2 Answers2

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.

EM-Creations
  • 4,195
  • 4
  • 40
  • 56
  • 1
    error_reporting(0) at the start of the script wont do the trick ? – Bhumi Singhal Feb 01 '13 at 10:37
  • 1
    and please explain how setting display_errors will be better than error_reporting. Thank you – Bhumi Singhal Feb 01 '13 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. – EM-Creations Feb 01 '13 at 10:42
0

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

Community
  • 1
  • 1
mjdevloper
  • 1,553
  • 8
  • 33
  • 69
  • I do have an htaccess but I am looking for the simplest possible solution ...and I guess php surely provides something to handle this :) – Bhumi Singhal Feb 01 '13 at 12:31