<?php
class db //Class beginning.
{
var $DB_HOST="localhost";
var $DB_USER="root";
var $DB_PASSWORD="";
var $DB="";
var $DB_TABLE="";
var $DB_LINK="";
var $DB_SELECT="mamati";
//Methods
function DisplayErrMsg( $message ) //Diplays errors if any.
{
printf("<blockquote><blockquote><blockquote><h3><font color=\"#cc0000\">%s</font></h3></blockquote></blockquote></blockquote>\n", $message);
}
//Connect to the db
function dbConnect() {
if (!($this->DB_LINK = mysql_connect($this->DB_HOST, $this->DB_USER, $this->DB_PASSWORD))) {
DisplayErrMsg(sprintf("internal error %d:%s\n", mysql_errno(), mysql_error()));
return 0;
} else {
$this->DB=mysql_select_db($this->DB_SELECT, $this->DB_LINK);
}
}
//Close connection.
function dbDisconnect()
{
if(!($closedb = mysql_close($this->DB_LINK)))
{
DIE ("Cannot close the db");
}
}
//Displays error in mysql.
} //Class end.
?>
I wrote this code but it didn't run like I want. I tested it with a non-existent database but the result is unexpected : the code works without any errors.Any help will be appreciated.Thanks.