PHP supplied argument is not a valid MySQL-Link resource 错误
写一函数提示出错
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in D:\www\func\include\mysql.class.php on line 86
代码如下:
require_once 'database.php';
require_once 'mysql.class.php';
/**
* 以语言类型获取最新列表
*@param $typeid 类型ID
*@param $count 调用个数
*@param $orderby 排序类型
*@return 返回数组
*
*/
function getFuncListByTypeId($typeid){
$mysql=new mysql();
$mysql->open($db);
$func_rows=$mysql->select('`id`,`name`,`classid`,`intro`,`content`,`datetime`,`click`', 'func_item','`typeid`='.$typeid );
return $func_rows;
}
require_once 'mysql.class.php';
/**
* 以语言类型获取最新列表
*@param $typeid 类型ID
*@param $count 调用个数
*@param $orderby 排序类型
*@return 返回数组
*
*/
function getFuncListByTypeId($typeid){
$mysql=new mysql();
$mysql->open($db);
$func_rows=$mysql->select('`id`,`name`,`classid`,`intro`,`content`,`datetime`,`click`', 'func_item','`typeid`='.$typeid );
return $func_rows;
}
原因是$db数组存在于'database.php'文件中不属于全局,在函数直接调用不了
解决办法:
在函数中: global $db;
搞了几个小时 汗 做个记号

浙公网安备 33010602011771号