PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<mysql_drop_dbmysql_error>
Last updated: Mon, 16 Jul 2012

mysql_errno

(PHP 3, PHP 4, PHP 5)

mysql_errno --  返回上一个 MySQL 操作中的错误信息的数字编码

说明

int mysql_errno ( [resource link_identifier] )

返回上一个 MySQL 函数的错误号码,如果没有出错则返回 0(零)。

从 MySQL 数据库后端来的错误不再发出警告,要用 mysql_errno() 来提取错误代码。注意本函数仅返回最近一次 MySQL 函数的执行(不包括 mysql_error()mysql_errno())的错误代码,因此如果要使用此函数,确保在调用另一个 MySQL 函数之前检查它的值。

例子 1. mysql_errno() 例子

<?php
   mysql_connect
("localhost", "mysql_user", "mysql_password");

  
mysql_select_db("nonexistentdb");
   echo
mysql_errno() . ": " . mysql_error(). "\n";

  
mysql_select_db("kossu");
  
mysql_query("SELECT * FROM nonexistenttable");
   echo
mysql_errno() . ": " . mysql_error() . "\n";
?>

以上例子将产生如下输出:

1049: Unknown database 'nonexistentdb'
1146: Table 'kossu.nonexistenttable' doesn't exist

注: 如果指定了可选参数则用给定的连接提取错误代码。否则使用上一个打开的连接。

参见 mysql_error()




<mysql_drop_dbmysql_error>
 Last updated: Mon, 16 Jul 2012
 
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://manual.phpv.net/
Last updated: Thu Jul 7 19:13:47 2005 CST