CJ7
CJ7

Reputation: 23295

Way to automatically send mysql errors and other errors to log file?

I have some PHP pages on a web host that perform some data access with a MySQL database.

Is there likely to be a setting somewhere in either the PHP or MySQl administration that will cause any errors, particularly MySQL errors, to be automatically logged to a file somewhere accessible to me as a customer of the web-host?

Alternatively, can I put something at the top of each PHP page that will achieve the same thing?

Upvotes: 2

Views: 204

Answers (1)

Hamcha
Hamcha

Reputation: 73

The long answer is to check for error at each MySQL action you perform

Example:

mysql_select_db($dbname)
or log_error(mysql_error());

The hacky way is to use output buffering to capture PHP errors when they would appear on the page.

Upvotes: 1

Related Questions