class UserAction { public function isLogged() { if($_SESSION['isLogged']) { return true; } else { return false; } } public function getUserData() { if($this -> isLogged()) { $query = prepare("SELECT COUNT(*) FROM ".$table_prefix."users WHERE userId = :userId"); $stmt -> execute($params); while($row = $stmt -> fetch()) { } } else { _e('pre','Już jesteś zalogowany!.'); } } public function userID() { $_SESSION['userId'] = $userId; return $userId; } }
i wywołanie kodu:
<?php try { $PDO = new PDO($DSN, $Username, $Password); $PDO -> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); { require_once THEMES.THEME.'/header'.ext; $UserAction = new UserAction; if($UserAction -> isLogged()) { $UserAction -> getUserData(); } else { $SystemAction -> redirect('index'); } require_once THEMES.THEME.'/footer'.ext; } else { _e('pre',"Nie można wczytać szablonu ".THEME." !."); } require_once TEMPLATES.'footer'.ext; } catch(PDOException $error) { _e('pre',"Połączenie nie mogło zostać utworzone: ".$error -> getMessage()." !."); } ?>
a błąd to:
Fatal error: Call to undefined function prepare() in /virtual/e/r/ervstudio.ugu.pl/system/class/UserAction.php on line 25
Co jest nie tak ?