Advertisement
Guest User

Untitled

a guest
May 30th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. <?php
  2. class MySQL_Connection{
  3. protected $database;
  4. protected function __construct($user, $password, $host){
  5. try{
  6. $RDBMS = strtolower('MySQL');
  7. $DBName = strtolower('DBName');
  8. $this->database = new PDO($RDBMS.":host"."=".$host.";".$DBName."="."PDirectory", $user, $password);
  9. }catch(PDOException $Exception){
  10. print $Exception->getMessage();
  11. exit;
  12. }
  13. }
  14. protected function __destruct(){
  15. $this->database = NULL;
  16. }
  17. }
  18. ?>
  19.  
  20. <?php
  21. require 'MySQL/Connect.php';
  22.  
  23. class MySQL_Login extends MySQL_Connection{
  24. private $QueryResult;
  25. public function __construct($user, $password, $host = 'localhost'){
  26. parent::__construct($user, $password, $host);
  27. }
  28. public function __destruct(){
  29. parent::__destruct();
  30. }
  31.  
  32. public function MySQL_Query($Username, $Password, $PIN, $ID){
  33. $Password = strtoupper(MD5($Password));
  34. $PIN = strtoupper(MD5($PIN));
  35. //Code the giving error -->
  36. $Query = MySQL_Connection::$connection->prepare("SELECT * FROM Users WHERE Username = ? AND Password = ? AND PIN = ? AND ID = ?");
  37. //Code the giving error <--
  38. $Query->execute(array(
  39. $Username,
  40. $Password,
  41. $PIN,
  42. $ID
  43. ));
  44.  
  45. $row = $Query->fetch(PDO::FETCH_ASSOC);
  46. if($row['ID'] != NULL){
  47. $this->QueryResult = $row['ID'];
  48. }else {
  49. $this->QueryResult = FALSE;
  50. }
  51.  
  52. }
  53. public function result() {
  54. return $QueryResult;
  55. }
  56. }
  57. ?>
  58.  
  59. PHP Notice: Accessing static property MySQL_Login::$database as non
  60. static in MySQL/Connect.php on line 17 -
  61.  
  62. PHP Fatal error: Uncaught Error: Access to undeclared static property:
  63. MySQL_Connection::$connection in Login.php on line 17 -
  64. Thrown in Login.php on line 17 -
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement