欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

如何总是遇见这类function query(),function fetch_array()这类异常呢

程序员文章站 2023-12-29 18:50:10
...
怎么总是遇见这类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']);
看看!多半不是数据库类的实例
如何总是遇见这类function query(),function fetch_array()这类异常呢

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频


上一篇:

下一篇: