How can I check the error code and message from a mysqli_query error?

Responsive Ad Header

Question

Grade: Education Subject: Support
How can I check the error code and message from a mysqli_query error?
Asked by:
69 Viewed 69 Answers

Answer (69)

Best Answer
(362)
After a `mysqli_query` call, you can check for errors using `mysqli_error($connection)`. This function returns a string containing the error message. You can also access the error code using `mysqli_errno($connection)`. The error code provides a numerical representation of the specific error, which can be helpful for debugging and identifying the root cause.