Jump to content

[SOLVED] MYSQL warning automatically getting appended to responseText property


sc0tt

Recommended Posts

Hello,

 

I made a call to a php script via ajax in my code . The php script tests for connection to a MYSQL database . If connection is successful , it echos "Connection Succeeded", and that correctly shows up in the responseText property.

However, if the connection fails , i have echoed "Connection failed" .

Now , the strange thing is that if the connection fails, the warning from mysql , which is as below, also gets appended to the text i have echoed.

 

Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host ....
Connection failed

 

How, can i prevent the warning from the mysql server from automatically getting appended to the responseText ?

 

Thank You.

Put error suppression operator(@) in front of your mysql_connect function.

 

just like this

 @mysql_connect("HOST","USERNAME","PASSWORD"); 

 

so basically what @ operator does is it will suppress the error handling mechanism by PHP.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.