Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set('mysql.connect_timeout', 5);
- class SQL {
- function __construct($config = "config.ini") {
- $this->config = parse_ini_file($config);
- $this->host = $this->config['Host'];
- $this->user = $this->config['User'];
- $this->pass = $this->config['Pass'];
- $this->dbname = $this->config['DBName'];
- $this->table = $this->config['Table'];
- }
- public function connect() {
- mysql_connect($this->host, $this->user, $this->pass) or die("[CRITICAL]Could not establish SQL connection.\n");
- mysql_select_db($this->dbname); or die("[CRITICAL]Could not select database.\n");
- }
- public function query($sql) {
- $query - mysql_query($sql);
- if(!$query) echo "[WARNING]Erorr with MySQL Query (".mysql_error().")\n";
- else echo "[MySQL]".$sql."\n";
- }
- function __destruct() {
- mysql_close();
- echo("[MySQL] Connection Closed.\n");
- die();
- }
- }
- ?>
Add Comment
Please, Sign In to add comment