我有这个我正在使用的脚本,并且在index.php上它从第15行的代码中给出了这个错误。
致命错误:在非对象上调用成员函数query()
这是整个index.php:
ob_start();
session_start();
if(file_exists("./install/install.lock"))
{
print "You must delete install.php";
exit;
}
elseif(file_exists("./install/update.lock"))
{
print "You must delete update.php";
exit;
}
$getuser = $os_DB->query("SELECT * FROM accounts WHERE id='".$_SESSION['userid']."'");
$ui = $os_DB->fetch($getuser);
//Check if IP is banned
$ip = $_SERVER['REMOTE_ADDR'];
$checkbanned = $os_DB->query("select * from banned where ip_addr='$ip'");
while($reason = $os_DB->fetch($checkbanned))
{
if($os_DB->num($checkbanned) != 0)
{
header("Location: site/banned");
}
}
//check if ip is a proxy
require_once('includes/classes/ProxStop.php');
// Perform Lookup
$result = $ProxStop->proxyLookup($ip,$ref);
// The lookup failed, print the error message.
if($result===false)
{
//echo 'The lookup failed with the error "'.$ProxStop->errors['code'].': '.$ProxStop->errors['msg'].'"';
}
// The IP is a proxy
elseif((int)$result->score>1)
{
$os_DB->query("INSERT INTO banned VALUES ('$ip')");
$os_DB->query("UPDATE accounts SET level=2 WHERE ip='$ip'");
header("Location: site/banned");
}
//Save Referral
if($_GET['ref'] != "")
{
$ref = $_GET['ref'];
setcookie("Referral", $ref, time()+3600, "/", $domain);
}
if(!defined("OS_THEME"))
{
print "This site has no theme defined";
die();
}
else
{
require_once($root . 'functions/functions.php');
if($settings['captcha_type'] == 3)
{
require "securimage/securimage.php";
$securimage = new Securimage();
}
include($root . 'header.php');
include($root . 'action.php');
include($root . 'footer.php');
}
?>
我不是程序员,所以我不知道该如何处理。我已阅读其他类似问题的帖子,但我不知道该怎么做。
答案 0 :(得分:1)
您的问题是$ os_DB尚未定义。如果你看一下第15行之前的代码
$getuser = $os_DB->query("SELECT * FROM accounts WHERE id='".$_SESSION['userid']."'");
你会发现这是第一次使用$ os_DB。你必须以某种方式定义$ os_DB。没有迹象表明这应该是什么类型的对象,但我想这是一种类似这样的数据库对象:
$os_DB = new db();