当mysql_query返回false时 [英] When mysql_query returns false

查看:371
本文介绍了当mysql_query返回false时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

mysql_query返回false时,除了编写错误的查询并且没有访问表的权限之外?还有其他情况吗?

Aside from writing the wrong query and not having permissions to access a table, when mysql_query returns false? Are there any other cases?

推荐答案

请参阅参考指南:

对于SELECT,SHOW,DESCRIBE,EXPLAIN和其他返回的语句 结果集,mysql_query()成功返回资源,否则返回FALSE 错误.

For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error.

对于其他类型的SQL语句,例如INSERT,UPDATE,DELETE,DROP等, mysql_query()成功返回TRUE,错误返回FALSE.

For other type of SQL statements, INSERT, UPDATE, DELETE, DROP, etc, mysql_query() returns TRUE on success or FALSE on error.

返回的结果资源应传递给mysql_fetch_array(), 和其他用于处理结果表的功能,以访问 返回的数据.

The returned result resource should be passed to mysql_fetch_array(), and other functions for dealing with result tables, to access the returned data.

使用mysql_num_rows()来查找返回的行数. SELECT语句或mysql_affected_rows()找出多少行 受DELETE,INSERT,REPLACE或UPDATE语句的影响.

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, INSERT, REPLACE, or UPDATE statement.

mysql_query()也会失败,如果用户不这样做则返回FALSE 有权访问查询所引用的表.

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的东西:

So we have list of things that can return false:

  • 当返回结果集的MySQL语句出现错误
  • 当不返回任何内容的MySQL语句出现错误
  • 当用户没有MySQL权限访问表引用时

在我看来,前2个有点分散.有哪些可能的错误?从MySQL可以得到59种不同的客户端错误.这些是更多与系统相关的错误,我们可以假定php将处理该错误,并且可能将其包装成更少量的抽象错误.

In my opinion the first 2 are the ones that are a bit diffuse. What are the possible errors? There are 59 different client errors you can get from MySQL. These are more system related errors which we can presume that php will handle and probably wrap into a smaller amount of abstract errors.

除了那些客户端错误外,您还会遇到一系列使用中可能遇到的抽象错误,这些错误与在应用程序内部使用实际API而不是对MySQL服务器的原始访问更为相关.这些是:

Except for those client errors you have a set of more abstract errors which you can encounter during usage which is more related to using the actual API inside the application rather than the raw access to the MySQL server. Those are:

  • 访问被拒绝
  • 无法连接到[本地] MySQL服务器
  • 与MySQL服务器的连接丢失
  • 客户端不支持身份验证协议
  • 交互式输入密码失败
  • 主机"host_name"被阻止
  • 连接过多
  • 内存不足
  • MySQL服务器不见了
  • 数据包太大
  • 通信错误和连接中断
  • 表已满
  • 无法创建/写入文件
  • 命令不同步
  • 忽略用户
  • 表'tbl_name'不存在
  • 无法初始化字符集
  • 表损坏问题
  • 与语法相关的问题
  • Access denied
  • Can't connect to [local] MySQL server
  • Lost connection to MySQL server
  • Client does not support authentication protocol
  • Password Fails When Entered Interactively
  • Host 'host_name' is blocked
  • Too many connections
  • Out of memory
  • MySQL server has gone away
  • Packet too large
  • Communication Errors and Aborted Connections
  • The table is full
  • Can't create/write to file
  • Commands out of sync
  • Ignoring user
  • Table 'tbl_name' doesn't exist
  • Can't initialize character set
  • Table corruption issues
  • Syntax related issues

以下是我刚才说的话:

  • 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

这篇关于当mysql_query返回false时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆