rawquery 没扎到返回什么_当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?

解决方案

See the reference guide:

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, INSERT, 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.

Edit: Clarification of what those errors actually are.

So we have list of things that can return false:

When a MySQL statement which returns a resultset gets an error

When a MySQL statement which doesn't return anything gets an error

When a user does not have MySQL permission to access a table reference

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.

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:

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

Here are the references of what I just said:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值