I thought that line might be causing trouble. Try reworking it to something like:
$query = @mysql_query($query,$this->connectionid);
if(!$query)
$this->log_error('mysql error:'.mysql_error().' query was: '.$query);
I thought that line might be causing trouble. Try reworking it to something like:
$query = @mysql_query($query,$this->connectionid);
if(!$query)
$this->log_error('mysql error:'.mysql_error().' query was: '.$query);
thanks,
the undefined function still exists though.
its not to do with my hosting running the CGI version of php instead of the Apache module?
I don't see why that would cause this issue, but then again, who knows... PHP.net has always recommended the module over the CGI binary :p
'Fraid this issue is beyond me. Sorry!
Could it have something to do with replacing the SQL statement with a resource id here? (using $query twice)
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;
}
indeed it does, maybe it loads the functions i differently because iv just tried it on another hosting account that uses the apache api and it works fine.
grr going to have to ask them to switch it to see if it really is the problem, but seems its something to do with hosting setup.
Can you show how you are calling the functions? The code here looks fine other than the missing 'error' function here:
$this->error('connect:no mysql functions',1);
m@tt wrote:Could it have something to do with replacing the SQL statement with a resource id here? (using $query twice)
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; }
thanks matt, the doesn't effect the issue with undefined function log_error,
but it wouldn't have passed the right data
i have changed to now read
function query($query)
{
$this->query_string = $query;
$result= @mysql_query($query,$this->connectionid) or $this->log_error('mysql error:'.mysql_error().' query was: '.$query);
$this->query_total++;
return $result;
}
I copied this class to my system and it works fine... no problem finding log_error function.
(call to error function is typo should be the same log_error)
like i always have done...
$database = new database;
$sql = "SELECT * FROM sometable";
if($database->query($sql))
{
//do something with result
}
are you running php with the apache module?
Yes, but I don't see how running in CGI would cause this unless it's reading syntax differently.
Maybe try putting brackets after the OR like
mysql_query() or ($this->log_error());
I love invisible problems
I honestly have no idea.... good luck
there great when you finally find the solution.
maybe CGI is?
iv tried putting log call in brackets and the suggestion made earlier by bradgrafelman
no change in the error.
im going to try and get my host to change from CGI to Module
just to see what happens,
iv tried it on my other hosting with module - works fine
youve tried it on your system using module - works fine
:/ can't be any other explaination other than a hosting setup issue surely?
thanks for your help m@tt and bradgrafelman
want to try renaming the function to 'log_error_new' just for kicks? lol
Fatal error: Call to undefined function: log_error_new() in /path/to/files/classes/class_database.php on line 31
What if you just call the log_error function, does it work?
$db = new database;
$db->log_error("Test",1);
I'm thinking it maybe has something to do with $this
hi iv found the problem and its not the CGI...
its unrelated to the actual database class
its where im calling its functions from
im trying to do a query from within another class called session
because session doesnt extend database
im accessing using the following
class session {
function session () {
database::query("SELECT QUERY");
}
}
because session class is outside the database class it sort of brings the query function from database into session the query fails calling the log_error which doesnt exist in session class
i have got round this by setting
global $database;
in each of the session functions that call the database class
$database->query();
instead of
database::query();
i could also do the following but i dont know if it will cause issues
class session extends database {
}