Code: Select all
<?php
/*DATABASE CLASS--------------------------------------------------------------*/
class database {
protected $db_user;
protected $db_pass;
protected $db_host;
protected $db_name;
protected $dbh;
public function __construct ($db_user, $db_pass, $db_host, $db_name) {
$this->db_user = $db_user;
$this->db_pass = $db_pass;
$this->db_host = $db_host;
$this->db_name = $db_name;
}
protected function connect() {
try {
$this->dbh = mysql_pconnect ($this->db_host, $this->db_user, $this->db_pass);
if (!is_resource($this->dbh)) {
throw new error (__CLASS__,
__FUNCTION__,
'database connection not a valid resource');
}
}
catch (error $e) {
echo '<p>Error in '.$e->getclass.'::'.$e->getfunction.': '.$e->getmsg.'</p>';
$e->senderror();
}
try {
if (!mysql_select_db($this->db_name, $this->dbh)) {
throw new error (__CLASS__,
__FUNCTION__,
'could not select database');
}
}
catch (error $e) {
echo '<p>Error in '.$e->getclass.'::'.$e->getfunction.': '.$e->getmsg.'</p>';
$e->senderror();
}
}
public function execute($query) {
if (!$this->dbh) {
$this->connect();
}
$result = mysql_query($query, $this->dbh);
try {
if (!$result) {
throw new error (__CLASS__,
__FUNCTION__,
'could not query database');
}
else if (!is_resource($result)) {
throw new error (__CLASS__,
__FUNCTION__,
'database result is not a valid resource');
} else {
return $result;
}
}
catch (error $e) {
echo '<p>Error in '.$e->getclass.'::'.$e->getfunction.': '.$e->getmsg.'</p>';
$e->senderror();
}
}
public function get_row($result) {
return mysql_fetcg_row($result);
}
public function get_assoc($result) {
return mysql_fetch_assoc($result);
}
public function get_array($result) {
return mysql_fetch_array($result);
}
}
/*ERROR CLASS-----------------------------------------------------------------*/
class error extends Exception {
protected $error_class;
protected $error_function;
protected $error_msg;
public function __construct ($error_class, $error_function, $error_msg) {
$this->error_class = $error_class;
$this->error_function = $error_function;
$this->error_msg = $error_msg;
}
public getclass () {
return $this->error_class;
}
public getfunction () {
return $this->error_function;
}
public getmsg () {
return $this->error_msg;
}
public senderror () {
$to = 'openhelpadmin@sbcglobal.net';
$subject = 'Error in '.$this->getclass.'::'.$this->getfunction.': '.$this->getmsg.'.';
$message = '<html>
<head>
<style type="text/ass">
body {
text-align:center;
font-family:sans-serif;
}
</style>
</head>
<body>
<p>Error in '.$this->getclass.'::'.$this->getfunction.': '.$this->getmsg.'.</p>
</body>
</html>';
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: OpenHelp <no-reply@openhelp.org>\r\n";
mail($to, $subject, $message, $headers);
}
}
?>Code: Select all
Parse error: parse error, unexpected T_STRING, expecting T_VARIABLE in /www/openhelp.org/beta/lib_classes.php on line 108Code: Select all
<?php
public getclass () {
?>Code: Select all
<?php
/*INCLUDE FILES---------------------------------------------------------------*/
require_once('conf_vars.php');
require_once('lib_classes.php');
/*DEFINE CURRENT PAGE---------------------------------------------------------*/
if (!$_GET['page']) {
$page_current = 'main';
} else {
$page_current = strip_tags(htmlspecialchars($_GET['page']));
}
/*MAKE PAGE-------------------------------------------------------------------*/
$database = new database($_CONFIG['db_user'],
$_CONFIG['db_pass'],
$_CONFIG['db_host'],
$_CONFIG['db_name']);
$database->execute('thiswillnotwork');
?>