mysql_error
(PHP 4, PHP 5)
mysql_error — 返回上一个 MySQL 操作产生的文本错误信息
说明
string mysql_error ([ resource $link_identifier ] )
返回上一个 MySQL 函数的错误文本,如果没有出错则返回 ''(空字符串)。如果没有指定连接资源号,则使用上一个成功打开的连接从 MySQL 服务器提取错误信息。
从 MySQL 数据库后端来的错误不再发出警告,要用 mysql_error() 来提取错误文本。注意本函数仅返回最近一次 MySQL 函数的执行(不包括 mysql_error() 和 mysql_errno())的错误文本,因此如果要使用此函数,确保在调用另一个 MySQL 函数之前检查它的值。
Example #1 mysql_error 例子
<?php
mysql_connect("localhost", "mysql_user", "mysql_password");
mysql_select_db("nonexistentdb");
echo mysql_errno() . ": " . mysql_error(). " ";
mysql_select_db("kossu");
mysql_query("SELECT * FROM nonexistenttable");
echo mysql_errno() . ": " . mysql_error() . " ";
?>
以上例子将产生如下输出:
1049: Unknown database 'nonexistentdb' 1146: Table 'kossu.nonexistenttable' doesn't exist
参见 mysql_errno()。
—-想了解更多的php相关异常处理怎么解决关注<计算机技术网(www.ctvol.com)!!>
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/phpttorial/86575.html