Home >Backend Development >PHP Tutorial >A detailed explanation of the PHP function mysql_error()_PHP tutorial
The syntax format of the PHP function mysql_error() when we use
is as follows:
string mysql_error ([resource $link_identifier])
The PHP function mysql_error() will return the error message generated by the previous MySQL function, or an empty string if there is no error.
The sample code for using the mysql_error() function is as follows:
<ol class="dp-xml"><li class="alt"><span><span class="tag"><</span><span> ?php </span></span></li><li><span>$</span><span class="attribute">connection</span><span>=</span><span class="attribute-value">mysql_connect<br /></span><span>("localhost","root","root") <br />or die("连接服务器失败"); </span></li><li class="alt"><span>mysql_select_db("mydb",$connection); </span></li><li><span>echo "错误信息:".mysql_error(); </span></li><li class="alt"><span class="tag">?></span><span> </span></span></li></ol>
The above is the specific use of the PHP function mysql_error().