For SELECT,SHOW,DESCRIBE,EXPLAIN and other statements returning
resultset,MysqL_query() returns a resource on success,or FALSE on
error.For other type of sql statements,INSERT,UPDATE,DELETE,DROP,etc,
MysqL_query() returns TRUE on success or FALSE on error.The returned result resource should be passed to MysqL_fetch_array(),
and other functions for dealing with result tables,to access the
returned data.Use MysqL_num_rows() to find out how many rows were returned for a
SELECT statement or MysqL_affected_rows() to find out how many rows
were affected by a DELETE,REPLACE,or UPDATE statement.MysqL_query() will also fail and return FALSE if the user does not
have permission to access the table(s) referenced by the query.
http://php.net/manual/en/function.mysql-query.php
编辑:澄清这些错误实际上是什么.
所以我们有可以返回false的东西的列表:
>返回一个结果集的MysqL语句会得到一个错误
>当一个没有返回任何东西的MysqL语句会出错
>当用户没有访问表参考的MysqL权限时
在我看来,前2个是有点分散的.有什么可能的错误?从MysqL可以得到59个不同的客户端错误.这些更系统的错误,我们可以假设PHP将处理,并且可能包含较少量的抽象错误.
除了这些客户端错误之外,还有一组更为抽象的错误,您可以在使用过程中遇到更多的错误,这些错误与在应用程序中使用实际的API相关,而不是原始访问MysqL服务器.那些是:
>拒绝访问
>无法连接到[本地] MysqL服务器
>失去与MysqL服务器的连接
>客户端不支持认证协议
>输入密码失败
>主机’host_name’被阻止
>连接太多
>内存不足
MysqL服务器已经消失
>包太大
>通信错误和异常连接
>表已满
>无法创建/写入文件
>命令不同步
>忽略用户
>表’tbl_name’不存在
>无法初始化字符集
>表损坏问题
>语法相关的问题
以下是我刚才说的内容:
> List of the client errors
> List of the common errors dealing with the API
> References about query related issues
> Table related issues
> Other issues related to known bugs