//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://
// PHP CLASS FILE
<?php
class db {
var $querynum = 0;
var $databhostname = 'localhost';
var $databname;
var $databusername = 'root';
var $databpassword;
var $fontatr = 'size="2" face="Verdana, Arial"';
var $pconnect = 0;
function connect($databhostname, $databname, $databusername,
$databpassword)
{
if ($this->pconnect != 0) {
$sql_link = @mysql_pconnect($databhostname, $databusername,
$databpassword);
} else {
$sql_link = @mysql_connect($databhostname, $databusername,
$databpassword);
}
if ($sql_link === false) {
echo "<div align=\"center\"><font $this->fontatr>[B]Error
establishing a database connection![/B]</font>[NUM][LI]<font $this->fontatr>Are
you sure you entered the correct user/password?</font>[LI]<font
$this->fontatr>Are you sure that you have typed the correct
hostname?</font>[LI]<font $this->fontatr>Are you sure that the database server
is running?</font>[/NUM]<font $this->fontatr>Please check your settings, if you
are not able to get it working send an email to your host!<br />This is the
error message returned by MySql: [I]" . mysql_errno() . ": " . mysql_error() .
"[/I]</div>";
exit();
}
$connection = @mysql_select_db($databname, $sql_link);
if ($connection === false) {
echo "<div align=\"center\"><font $this->fontatr>[B]Error
accessing the database: $databname![/B]</font>[NUM][LI]<font $this->fontatr>Are
you sure you entered the correct database name and the database
exists?</font>[LI]<font $this->fontatr>Are you sure that you have permission to
access this database?[/NUM]<font $this->fontatr>Please check your settings, if
you are not able to get it working send an email to your host!<br />This is the
error message returned by MySql: [I]" . mysql_errno() . ": " . mysql_error() .
"[/I]</div>";
exit();
}
}
function query($input)
{
$output = @mysql_query($input);
if (empty($output)) {
if (ereg('errno: 145', mysql_errno())) {
// repair_tables();
} else {
echo "<div align=\"center\"><font $this->fontatr>[B]Error
querying the database![/B]</font>[NUM][LI]<font $this->fontatr>Check the input
for invalid characters...</font>[LI]<font $this->fontatr>Inform the NS Forums
Developer @
http://www.nswmd.com/nsforums/[/NUM]<br />This is the query NS
Forums tried to execute: $input<br />This is the error message returned by
MySql: [I]" . mysql_errno() . ": " . mysql_error() . "[/I]</div>";
}
exit();
}
$this->querynum++;
return $output;
}
function unbuffered_query($input)
{
mysql_unbuffered_query($input) or die("Error:" . mysql_error());
$this->qn++;
return;
}
function fetch_array($input, $type = MYSQL_ASSOC)
{
$output = @mysql_fetch_array($input, $type);
return $output;
}
function num_rows($query)
{
$output = @mysql_num_rows($query);
if ($output === false) {
$output = 0;
}
return $output;
}
function result($query, $row = 0)
{
$output = @mysql_result($query, $row);
return $output;
}
function insert_id()
{
$output = @mysql_insert_id();
return $output;
}
function free_result($info)
{
$output = @mysql_free_result($info);
return $output;
}
}
?>