Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. <?php
  2. CLASS DB_Class {
  3. var $db;
  4. ///////////////////////////
  5. FUNCTION DB_Class($hostname, $dbname, $username, $password) {
  6. $this->db = MYSQL_CONNECT ($hostname, $username, $password)
  7. or DIE ("Unable to connect to Database Server");
  8.  
  9. MYSQL_SELECT_DB ($dbname, $this->db) or DIE ("Could not select database");
  10. }
  11.  
  12. FUNCTION query($sql) {
  13. $result = MYSQL_QUERY ($sql, $this->db) or DIE ("Invalid query: " . MYSQL_ERROR());
  14. RETURN $result;
  15. }
  16. ///////////////////////////
  17. FUNCTION getone($sql) {
  18. $result = $this->query($sql);
  19.  
  20. IF(MYSQL_NUM_ROWS($result) == 0)
  21. $value = FALSE;
  22. ELSE
  23. $value = MYSQL_RESULT($result, 0);
  24. RETURN $value;
  25. }
  26. ///////////////////////////
  27. }
  28. ?>
  29. <?PHP
  30. $hostname=$_POST['host'];
  31. $db=$_POST['db'];
  32. $user=$_POST['user'];
  33. $password=$_POST['password'];
  34. $dbconnect = NEW DB_Class($hostname, $db, $user, $password);
  35. $query = "SELECT * FROM users";
  36. $result = mysql_query($query);
  37. while($line=mysql_fetch_array($result)){
  38. echo $line;
  39. }
  40.  
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement