Dennis
Here is a snippet of the error message:
Notice: Undefined variable: db in D:DAdennismdb_search.php on line 32
Fatal error: Call to a member function get_results() on a non-object in D:DAdennismdb_search.php on line 32
At the beginning of the error page I get this:
dbh = @mysql_connect($dbhost,$dbuser,$dbpassword); if ( ! $this->dbh ) { $this->print_error("
- Error establishing a database connection!
- Are you sure you have the correct user/password?
- Are you sure that you have typed the correct hostname?
- Are you sure that the database server is running?
I am not an OO expert by any manys but I have a feeling that the variable "db" is not considered to be an object because of the way it is used in the get_results function. Here is the function directly from the class I am using.
// Return the the query as a result set - see docs for more details
function get_results($query=null, $output = OBJECT)
{
// Log how the function was called
$this->func_call = "$db->get_results("$query", $output)";
// If there is a query then perform it if not then use cached results..
if ( $query )
{
$this->query($query);
}
// Send back array of objects. Each row is an object
if ( $output == OBJECT )
{
return $this->last_result;
}
elseif ( $output == ARRAY_A || $output == ARRAY_N )
{
if ( $this->last_result )
{
$i=0;
foreach( $this->last_result as $row )
{
$new_array[$i] = get_object_vars($row);
if ( $output == ARRAY_N )
{
$new_array[$i] = array_values($new_array[$i]);
}
$i++;
}
return $new_array;
}
else
{
return null;
}
}
}







4 Comments
function my_func()
{
global $db;
$db->query("insert blah into blah");
}
Thanks
Thanks
Hey you know AdGuy always gets the last word! ;)