Home >Backend Development >PHP Problem >How to get mysql error message in php
php method to obtain mysql error information: You can use the mysql_error() function to obtain it. The mysql_error() function can return the text error message generated by the previous mysql operation, or an empty string if there is no error.
The mysql_error() function returns the text error message generated by the previous MySQL operation, or an empty string if there is no error.
(Recommended tutorial: php graphic tutorial)
Grammar:
mysql_error(connection)
(Recommended learning video: php video tutorial )
Example:
<?php $con = mysql_connect("localhost","wrong_user","wrong_pwd"); if (!$con) { die(mysql_error()); } mysql_close($con); ?>
Output result:
Access denied for user 'wrong_user'@'localhost' (using password: YES)
The above is the detailed content of How to get mysql error message in php. For more information, please follow other related articles on the PHP Chinese website!