Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. <?php
  2. class Database{
  3. var $con =0;
  4. function Database($dbname="", $dbhost="", $dbusername="", $dbpass="")
  5. {
  6. $this->dbname = $dbname;
  7. $this->dbhost = $dbhost;
  8. $this->dbusername = $dbusername;
  9. $this->dbpass = $dbpass;
  10. }
  11.  
  12. function connect() {
  13. $this->con =@mysql_connect($this->dbhost,$this->dbusername,$this->dbpass, false);
  14.  
  15. if (!$this->con) {//open failed
  16. return false;
  17. }
  18.  
  19. if(!@mysql_select_db($this->dbname, $this->con)) {//no database
  20. return false;
  21. }
  22.  
  23. // unset the data so it can't be dumped
  24. $this->dbhost='';
  25. $this->dbusername='';
  26. $this->dbpass='';
  27. $this->dbname='';
  28. }
  29.  
  30.  
  31.  
  32. }
  33. //execute query
  34. function setQuery($sql)
  35. {
  36. echo 'This is a test';
  37.  
  38. // do query
  39. $this->query_id = @mysql_query($sql, $this->con);
  40.  
  41. if (!$this->query_id) {
  42. echo "<b>MySQL Query fail:</b> $sql";
  43. return 0;
  44. }
  45.  
  46. return true;
  47. }//EOF
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement