Advertisement
Guest User

Untitled

a guest
Mar 16th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. // Do we have a valid database connection and have we selected a database?
  2. public function databaseSelected()
  3. {
  4. if(!$this->isConnected()) return false;
  5. $result = mysql_list_tables($this->name, $this->db);
  6. return is_resource($result);
  7. }
  8.  
  9. public function connect()
  10. {
  11. $this->db = @mysql_connect($this->host, $this->username, $this->password) or $this->notify('Failed connecting to the database with the supplied connection details. Please check the details are correct and your MySQL user has permissions to access this database.<br/><br/>(host: '.$this->host.', user: '.$this->username.', pass: ********)');
  12. if($this->db === false) return false;
  13. mysql_select_db($this->name, $this->db) or $this->notify(); if($this->isConnected())
  14. {
  15. mysql_set_charset('UTF-8', $this->db);
  16. $this->query("SET NAMES utf8");
  17. }
  18.  
  19. return $this->isConnected();
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement