Skip to content
Advertisement

issues printing last error message in php

I am trying to connect to a MySQL database using PHP, but I am getting 32767 error reporting in the console. I tried to show the error message using echo error_reporting() but it is not showing the error message.

Here is the code:

JavaScript

How can I get the content of the error message?

Advertisement

Answer

error_reporting() => Sets which PHP errors are reported

To get/handle errors you have to use functions like error_get_last or set_error_handler

In your case you want to get the MySql error, so you have to use mysqli_error or mysqli_errno

JavaScript

Like Quentin noted you are vulnerable to SQL injection attacks. So please use mysqli_real_escape_string or mysqli_prepare.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement