How to log or see all MySQL errors? I have a website, which collects input from the user. When his data cannot be inserted into a database, I simply display "Sorry..." I am hosting my website on LAMP. I am new to MySQL and would like to know how to log all the errors. For example, I want to log/see why exactly user was not able to submit data properly: maybe he violated integrity constraints etc. Is it possible to do?
In PHP, consider using

error_log($str);


It will write to the web server's log file.

$str should be constructed from diagnostics provided by MySQL or php.  You might consider prefixing the string with some keyword to make the log file more easily searchable.

Alas, this means identifying all places in your code that might have "errors" or "warnings" and adding code to grab the relevant message.  But it does put all the messages into a central location for later study.