Advertisement
Guest User

Untitled

a guest
Mar 14th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. $servername = "****";
  2. $database = "****";
  3. $username = "****";
  4. $password = "****";
  5.  
  6. try {
  7. $pdo = new PDO("mysql:host=$servername;dbname=$database", $username, $password);
  8. $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  9. } catch(PDOException $e) {
  10. echo "Connection failed: " . $e->getMessage();
  11. }
  12.  
  13. class Database {
  14.  
  15. protected $pdo;
  16.  
  17. public function __construct($pdo) {
  18. $this->pdo = $pdo;
  19. }
  20. }
  21.  
  22. class User extends Database {
  23.  
  24. private $ip;
  25. private $sessionId;
  26.  
  27. public function __construct($ip, $sessionId) {
  28. $this->ip = $ip;
  29. $this->sessionId = $sessionId;
  30. }
  31. public function getSessionInfo () {
  32. $stmt = $this->pdo->prepare(".."); <-- error here
  33. ....
  34. }
  35. }
  36.  
  37. require_once 'api/core.php';
  38. $database = new Database($pdo);
  39. $user = new User($_SERVER['REMOTE_ADDR'], $_SESSION['info']['id']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement