ERROR:
Fatal error: Call to a member function query() on a non-object in .../inc_sql.php on line 27
I have searched and searched and have not been able to fuigure this out I appreciate any help.
Code: Select all
<?PHP
//global $dbc;
$dbc = new DBI;
if (realpath(__FILE__) == realpath($_SERVER['SCRIPT_FILENAME'])) exit('This file can not be accessed directly...');
class DBI
{
public $dbconn, $nfreed;
private $result, $threads;
function __construct()
{
if(basename($_SERVER['SCRIPT_NAME'])=="message.php" && $_GET['error']) return "";
$this->nfreed=false;
$sqlhost = "IP";
//$sqlhost = "localhost";
@$this->dbconn = new mysqli($sqlhost, "USER", "PASS", "DATABASE");
if(mysqli_connect_errno()) header("Location: message.php?error=sqlserver");
//die("Critical Error: ".mysqli_connect_error());
}
function query($sql, $flag = MYSQLI_STORE_RESULT)
{
//echo("<p>".$sql."</p>");
if($this->nfreed) {$this->free();}
[b] if(!$this->result = $this->dbconn->query($sql)) header("Location: message.php?error=sqlcmd&errno=".$this->dbconn->errno);[/b]
//die("<pre>Mysql Error: ".$this->dbconn->error."</pre>");
$this->nfreed=true;
return $result;
}
function get_threads() {
global $threads;
if($threads==""){
ereg ("Threads: (...)", $this->dbconn->stat(), $regs);
$threads = trim($regs[1]);
}
return $threads;
}Any help is greatly appreciated!