Simple Class Connection


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <php
  2. /**
  3. * Simple Class Connect
  4. */
  5.  
  6. class Connect {
  7.  
  8. var $host="localhost";
  9. var $dbname="yourdatabase";
  10. var $usuario="userserver";
  11. var $password="passwordserver";
  12. var $link;
  13. var $unlink;
  14.  
  15. function onServer()
  16. {
  17. $this->link = mysql_connect($this->host, $this->usuario, $this->password);
  18. $this->database = mysql_select_db($this->dbname);
  19. }
  20.  
  21.  
  22. function offServer()
  23. {
  24. $this->unlink = mysql_close($this->link);
  25. }
  26.  
  27. }
  28.  
  29. $var = new Connect();
  30. $var->onServer();
  31. echo 'run your queries here';
  32. $var->offServer();
  33. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.