h2008diau
(h2008diau)
新手上路

初级会员
UID 29790
精华
0
积分 17
帖子 15
金钱 17 喜悦币
威望 0
人脉 0
阅读权限 10
注册 2004-7-2
状态 离线
|
关于$this->mysql_error()问题的请教
用这个类出现下面的问题,不知是什么毛病,请高手指点一下.
Fatal error: Using $this when not in object context in F:\LOGO\web\db_mysql_error.php on line 7
第七行作了标记
文件db_mysql.php
<?php
class dbstuff {
var $querynum = 0;
function connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect = 0) {
if($pconnect) {
if(!mysql_pconnect($dbhost, $dbuser, $dbpw)) {
$this->halt('Can not connect to MySQL server');
}
} else {
if(!mysql_connect($dbhost, $dbuser, $dbpw)) {
$this->halt('Can not connect to MySQL server');
}
}
mysql_select_db($dbname);
}
function select_db($dbname) {
return mysql_select_db($dbname);
}
function fetch_array($query, $result_type = MYSQL_ASSOC) {
return mysql_fetch_array($query, $result_type);
}
function query($sql, $silence = 0) {
$query = mysql_query($sql);
if(!$query && !$silence) {
$this->halt('MySQL Query Error', $sql);
}
$this->querynum++;
return $query;
}
function unbuffered_query($sql, $silence = 0) {
$func_unbuffered_query = @function_exists('mysql_unbuffered_query') ? 'mysql_unbuffered_query' : 'mysql_query';
$query = $func_unbuffered_query($sql);
if(!$query && !$silence) {
$this->halt('MySQL Query Error', $sql);
}
$this->querynum++;
return $query;
}
function affected_rows() {
return mysql_affected_rows();
}
function error() {
return mysql_error();
}
function errno() {
return mysql_errno();
}
function result($query, $row) {
$query = @mysql_result($query, $row);
return $query;
}
function num_rows($query) {
$query = mysql_num_rows($query);
return $query;
}
function num_fields($query) {
return mysql_num_fields($query);
}
function free_result($query) {
return mysql_free_result($query);
}
function insert_id() {
$id = mysql_insert_id();
return $id;
}
function fetch_object($query) {
$query = mysql_fetch_object($query);
return $query;
}
function fetch_row($query) {
$query = mysql_fetch_row($query);
return $query;
}
function close() {
return mysql_close();
}
function halt($message = '', $sql = '') {
include 'db_mysql_error.php';
}
}
?>
文件db_mysql_error.php
<?
$timestamp = time();
$errmsg = '';
$dberror = $this->error();//出错的第七行
$dberrno = $this->errno();
if($dberrno == 1114) {
?>
<html>
<head><title>Max onlines reached</title></head>
<body>
<table cellpadding="0" cellspacing="0" border="0" width="500" height="90%" align="center" style="font-family: Verdana, Tahoma;font-size: 9px;color: #000000">
<tr><td height="50%"> </td></tr><tr><td valign="middle" align="center" bgcolor="#EAEAEA">
<br><b style="font-size: 11px;">Forum onlines reached the upper limit</b><br><br><br>Sorry, the number of online visitors has reached the upper limit.<br>Please wait for someone else going offline or visit us in idle hours.<br><br></td>
</tr><tr><td height="50%"> </td></tr></table>
</body>
</html>
<?
exit;
} else {
$errmsg .= "<b>Time</b>: ".gmdate("Y-n-j g:ia", $timestamp + ($GLOBALS["timeoffset"] * 3600))."\n";
$errmsg .= "<b>Script</b>: ".$GLOBALS[PHP_SELF]."\n\n";
if($sql) {
$errmsg .= "<b>SQL</b>: ".htmlspecialchars($sql)."\n";
}
$errmsg .= "<b>Error</b>: $dberror\n";
$errmsg .= "<b>Errno.</b>: $dberrno";
echo "</table></table></table></table></table>\n";
echo "<p style=\"font-family: Verdana, Tahoma; font-size: 11px; background: #FFFFFF;\">";
echo nl2br($errmsg);
echo '</p>';
exit;
}
?>
|
|