Suppress mysql errors on php

2019-02-20 01:36发布

问题:

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 .

回答1:

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.



回答2:

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