Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $servername = "****";
- $database = "****";
- $username = "****";
- $password = "****";
- try {
- $pdo = new PDO("mysql:host=$servername;dbname=$database", $username, $password);
- $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- } catch(PDOException $e) {
- echo "Connection failed: " . $e->getMessage();
- }
- class Database {
- protected $pdo;
- public function __construct($pdo) {
- $this->pdo = $pdo;
- }
- }
- class User extends Database {
- private $ip;
- private $sessionId;
- public function __construct($ip, $sessionId) {
- $this->ip = $ip;
- $this->sessionId = $sessionId;
- }
- public function getSessionInfo () {
- $stmt = $this->pdo->prepare(".."); <-- error here
- ....
- }
- }
- require_once 'api/core.php';
- $database = new Database($pdo);
- $user = new User($_SERVER['REMOTE_ADDR'], $_SESSION['info']['id']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement