php expects parameter 1 to be resource, array given 错误
2011-03-23 21:38
721 查看
如果你使用的是封装好的类
例如
function fetch_array($query, $result_type = MYSQL_ASSOC) {
return mysql_fetch_array($query, $result_type);
}
[/code]
会报这个错误
这是应为,你传递的$query是布尔值,而mysql_fetch_array 里面的参数需要的是资源类型,这是,你的程序会判定你传递的参数错误,
我们可以
复制代码 代码如下:
function fetch_array($query, $result_type = MYSQL_ASSOC) {
return @mysql_fetch_array($query, $result_type);
}
在前面使用@来禁止错误提示,或者
试用判读语句来执行这个语句,
复制代码 代码如下:
if(这个参数)
{
执行
}
例如
function fetch_array($query, $result_type = MYSQL_ASSOC) {
return mysql_fetch_array($query, $result_type);
}
[/code]
会报这个错误
这是应为,你传递的$query是布尔值,而mysql_fetch_array 里面的参数需要的是资源类型,这是,你的程序会判定你传递的参数错误,
我们可以
复制代码 代码如下:
function fetch_array($query, $result_type = MYSQL_ASSOC) {
return @mysql_fetch_array($query, $result_type);
}
在前面使用@来禁止错误提示,或者
试用判读语句来执行这个语句,
复制代码 代码如下:
if(这个参数)
{
执行
}
相关文章推荐
- php expects parameter 1 to be resource, array given 错误
- expects parameter 1 to be resource, array given 错误解析
- expects parameter 1 to be resource, array given 错误
- Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in E:\\PHP\\wamp\\www\\lsr\\lsr.php on line 42
- Warning:mysql_num_rows() expects parameter 1 to be resource,boolean given in F:.....\db_func.php onl
- ArrayAdapter requires the resource ID to be a TextView错误
- 错误 java.lang.ClassCastException: com.xx cannot be cast to ResourceBundle
- The PHP cURL extension must be installed to use Guzzle 错误: ubuntu 安装 php-curl 拓展
- ArrayAdapter requires the resource ID to be a TextView错误
- PHP Warning: mysql_num_rows() expects parameter 1 to be resource
- ecshop出现 readdir() expects parameter 1 to be resource, boolean given 错误
- 编译PHP错误:undefined reference to `ts_resource_ex'
- ArrayAdapter requires the resource ID to be a TextView错误
- php访问数据库出错:Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given i
- 编译PHP错误:undefined reference to `ts_resource_ex'
- php连接MySQL时产生错误:mysqlnd cannot connect to MySQL 4.1+ using old authentication
- 新建flex Library Project项目错误 Nothing Was Specified to be included in the library
- mysql workbench 错误 Error Code: 1046. No database selected Select the default DB to be used by doubl
- VS2010编译错误 #error : This file requires _WIN32_WINNT to be #defined at least to 0x0403的解决方法
- 解决NVelocity加载模板时出现Unable to find resource"xxx"错误