4

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

3
  • 3
    Can you post some of the code? Commented May 22, 2014 at 7:25
  • 1
    Can you show us the entire error message? (To try to figure out where it is originating from) Commented May 22, 2014 at 7:55
  • you are setting 'display_errors' to 1 thus showing errors? Commented May 22, 2014 at 9:24

4 Answers 4

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

It was indeed issue with xdebug and another extension.
0

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

1 Comment

It's true that's best, but it won't make the website function.
0

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);

Comments

0

try this instead

ini_set('display_errors', 0);

error_reporting(E_ERROR); OR error_reporting(0);

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.