Home > Backend Development > PHP Tutorial > 如何总是遇见这类function query(),function fetch_array()这类异常呢

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

WBOY
Release: 2016-06-13 11:54:56
Original
930 people have browsed it

怎么总是遇见这类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']); 
看看!多半不是数据库类的实例

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template