1

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?

CJ7
  • 20,640
  • 59
  • 173
  • 305
  • Maybe this can be useful for you http://stackoverflow.com/questions/3531703/how-to-log-errors-and-warnings-into-a-file – Yago Riveiro Nov 13 '12 at 11:03

1 Answers1

0

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.

Hamcha
  • 63
  • 1
  • 6
  • I see that you are using a lazy-OR to cause the `log_error` to execute if the `mysql_select` fails. Is it possible for a PHP installation to have been configured not to do lazy-ORs? – CJ7 Nov 13 '12 at 12:33
  • I don't think so, it's kind of a shorthand for `if(!mysql_select_db($dbname)) log_error(mysql_error());` – Hamcha Nov 25 '12 at 11:13