加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 当mysql_query返回false时

发布时间:2020-12-13 17:34:52 所属栏目:PHP教程 来源:网络整理
导读:除了编写错误的查询,还没有访问表的权限,当 mysql_query返回false?还有其他情况吗? 参见参考指南: For SELECT,SHOW,DESCRIBE,EXPLAIN and other statements returning resultset,mysql_query() returns a resource on success,or FALSE on error. For oth
除了编写错误的查询,还没有访问表的权限,当 mysql_query返回false?还有其他情况吗?
参见参考指南:

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读