/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//////////////////////////////////// //Simple DB Connection class. //////////////////////////////////// class dbconnect { //Variables. private $host; private $user; private $password; private $database; private $lnk; public $result; //////////////////////////// //Constructor. //////////////////////////// public function __construct($a, $b, $c, $d) { $this -> host = $a; $this -> user = $b; $this -> password = $c; $this -> database = $d; } //////////////////////////// //Public class functions. //////////////////////////// //Query public function func_query($qstring) { $this -> func_connect(); return $this -> result; } //////////////////////////// //Private class functions. //////////////////////////// //Connect. private function func_connect() { $this -> lnk = mysql_connect($this -> host, $this -> user, $this -> password, true) OR die('Could not connect to the database - Why: '.mysql_error()); } //////////////////////////// //Destructor. //////////////////////////// public function __destruct() { } } ////////////////////////////////////