Okay, so I'm doing a small re-code to a site I operate. I am moving to OOP, and with that, I am having issues. I have it set up so that I have all my functions in one file (inc.functions.php). I have a database connector class (class.database.php) which utilizes a function if there is an error. Unfortunately, it seems that scope is an issue in this.
So I researched the "::" and public items on php.net. Still, not quite understanding what's going on. I declare my funcitons as 'function name(){}'. If I go to utilize a function, it tells me it is an invalid function, but the file is included. Any ideas here? Not too sure where to look, or how to go about debugging it. I know it's something simple, but i can't seem to get it.
~Brett
class.database.php
class database
{
var $conn;
var $query;
function dbConn()
{
global $db;
$this->conn = @mysql_connect($db['host'], $db['user'], $db['pass']);
if(!$this->conn)
{
$er['errors'] = TRUE;
$er['error'] = throw_error('mySQL Connection Error', mysql_errno(), mysql_error());
return $er;
}
else
{
if(!@mysql_select_db($db['db'], $this->conn))
{
$er['errors'] = TRUE;
$er['error'] = throw_error('mySQL Database Error', mysql_errno(), mysql_error());
return $er;
}
else
{
return TRUE;
}
}
}
inc.functions.php
function throw_error($title, $num, $err)
{
$error = '<div class="article">
<span class="title">'.$title.'</span>
<p class="story">';
$error .= (!empty($num) && $num != '')? '<b>'.$num.'</b><br />':'';
$error .= $err.'</p>
<span class="posted">'.date("F d, Y").'</span>
</div>';
alertWebmaster($title, $num, $err);
return $error;
}
// More functions, all formatted as above;