简体   繁体   中英

PHP MySQL Error Setting

I have developed some php/mysql code on linux machine, and it runs fine. On client's machine running wamp server on windows, same operation gives a mysql error - which Php is displaying neatly in a tabular format. The error is in a mysql query with INSERT, pertaining to Duplicate Keys. ( I know I can use ON DUPLICATE KEY UPDATE , but that is not the issue ). Problem is, the code is supposed to handle errors gracefully.

It does on my linux machine, but on client's wamp - it displays html tables with error details. I tried try and catch around the function call, but that also does not prevent the error from getting displayed in the browser (the PHP file is supposed to emit json data for ajax calls, that is why I cannot afford to have those error display by PHP).

Also, in the php file, I have

ini_set('display_errors', 1); error_reporting(E_ALL);

and still, since its a mysql error, it rightly does not throw any php error on linux, but does on windows.

So basically, I want to know what PHP setting (or something else?) on client's machine could be causing the MySQL error to be propagated / processed by PHP, and how to turn it off.

Thanks

You might want to check your php.ini and look at these values:

xdebug.auto_trace=1
xdebug.trace_format=1
mysql.trace_mode = On
pdo_mysql.debug = On

If they are there, disable them

its better to make error_reporting(0); in start of your code when you put your code on live server , its is better to hide un necessary errors and notifications

First make sure your MySQL version numbers are the same!

If you are using mysqli try having the following:

mysqli_report(MYSQLI_REPORT_OFF);

If you want to turn it on with the Linux stack, try something like this:

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

try this instead

ini_set('display_errors', 0);

error_reporting(E_ERROR); OR error_reporting(0);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM