您好,欢迎访问一九零五行业门户网

怎么总是遇见这类function query(),function fetch_array()这类错误呢

/**
 * 生成数据库备份文件
 */
function sql_dumptable($table, $vol_size, $startfrom = 0, $currsize = 0)
{
global $startrow;
$allow_max_size = intval(@ ini_get('upload_max_filesize')); //单位m
if ($allow_max_size > 0 && $vol_size > ($allow_max_size * 1024))
{
$vol_size = $allow_max_size * 1024; //单位k
}
if ($vol_size > 0)
{
$vol_size = $vol_size * 1024;
}
if (!isset ($tabledump))
{
$tabledump = '';
}
$offset = 100;
if (!$startfrom)
{
$tabledump = drop table if exists $table;\n;
$sql=show create table .$table.;
$createtable = $globals['zangbao']->query($sql);                        $create = $globals['zangbao']->fetch_array($createtable);
$tabledump .= $create[1] . ;\n\n;
if ($globals['zangbao']->version() > '4.1' && $this->sqlcharset)
{
$tabledump = preg_replace(/(default)*\s*charset=[a-za-z0-9]+/, default charset= . $this->sqlcharset, $tabledump);    
}
}
$tabledumped = 0;
$numrows = $offset;
while ($currsize + strlen($tabledump)  {
$tabledumped = 1;
$rows = $globals['zangbao']->query(select * from $table limit $startfrom, $offset);
$numfields = $globals['zangbao']->num_fields($rows);
$numrows = $globals['zangbao']->num_rows($rows);
while ($row = $globals['zangbao']->fetch_array($rows))
{
$comma = ;
$tabledump .= insert into $table values(;
for ($i = 0; $i  {
$tabledump .= $comma . ' . $globals['zangbao']->escape_string($row[$i]) . ';
$comma = ,;
}
$tabledump .= );\n;
}
$startfrom += $offset;
}
$startrow = $startfrom;
$tabledump .= \n;
return $tabledump;
}
fatal error: call to a member function query() on a non-object in e:\wamp\www\zangbaoshengwu\admin\include\backup.class.php on line 108
我这是做的数据库备份恢复程序,红色那行和下面的一行总是出错,我已经在类文件里面定义了的
回复讨论(解决方案) print_r($globals['zangbao']); 
看看!多半不是数据库类的实例
print_r($globals['zangbao']); 
看看!多半不是数据库类的实例
还真是数据库类实例的问题,把类实例名给换了,这里却没有换,太粗心了 所以数据库类还是用单例模式或通过函数调用比较好
版主问下,我mysql数据是中文,但是导出的脚本里面中文成乱码了
其它类似信息

推荐信息