Hi i have created a very basic database class,
im getting
Fatal error: Call to undefined function: log_error() in /path/to/files/classes/class_database.php
heres the code in the class
you can see clearly that the function log_error() is defined within the class
Hopefully someone can tell me why its giving me this error.
class database {
var $connectionid;
var $query_string;
var $query_total;
function connect()
{
if(function_exists('mysql_connect'))
{
$this->connectionid = mysql_connect('localhost',DATABASE_USER,DATABASE_PASS) or $this->log_error('connect:'.mysql_error(),1);
mysql_select_db(DATABASE_NAME,$this->connectionid) or $this->log_error('connect:'.mysql_error(),1);
}
else
{
$this->error('connect:no mysql functions',1);
}
}
function query($query)
{
$this->query_string = $query;
$query = @mysql_query($query,$this->connectionid) or $this->log_error('mysql error:'.mysql_error().' query was: '.$query);
$this->query_total++;
return $query;
}
function last_id()
{
return @mysql_insert_id($this->connectionid);
}
function fetch_array($query)
{
$query = @mysql_fetch_array($query);
return $query;
}
function fetch_row($query)
{
$query = @mysql_fetch_row($query);
return $query;
}
function num_rows($query)
{
$query = @mysql_num_rows($query) or $this->log_error('num_rows:'.mysql_error());
return $query;
}
function log_error($errstr,$fatal=0)
{
if(strlen($errstr) > 10)
{
session_error('A database error occured.',1);
$f = @fopen('log/database.log','a');
$errstr = $this->connectionid." [".date('d/m/Y H:i')."] - ".$errstr;
if($f)
{
fwrite($f,$errstr."\n",strlen($errstr));
@fclose($f);
}
if($fatal)
{
header("HTTP/1.0 503 Service Unavailable");
die('Our system is currently unavailable, Maintainence work should be finished shortly. Thanks for your co-operation.');
}
}
}
function close()
{
mysql_close($this->connectionid);
}
}