0

Why does PDO not fetch here?: $userInfo = $user->fetch();

//User Data
$user = $dbh->prepare('SELECT * FROM users JOIN levels ON users.level = levels.level WHERE users.id = :id and users.login = :login LIMIT 1');
$userID = $_SESSION['userID'];
$loginName = $_SESSION['loginName'];
$user->execute(array(':id' => $userID, ':login' => $loginName));
$userInfo = $user->fetch();
$lvlPerc = ($userInfo['users.xp'] / $userInfo['levels.xp']) * 100;

//Check if banned or !Authorized
if ($userInfo['status'] != "2") {
    session_destroy();
    unset ($_SESSION['userID']);
    unset ($_SESSION['userLogin']);
    header ("Location: /login");
    exit();
}
MMQVBN
  • 35
  • 4
  • If `$user->fetch()` fails, either your query is invalid or your parameters are not set/wrong values. – Sean Jan 15 '17 at 04:26
  • 1
    Who knows, your code is written in such a way **you** expect everything is going as expected. `prepare()` returns a *bool*, `execute()` returns a *bool* and `fetch()` returns a mix, that you can compare against a *bool*. – Xorifelse Jan 15 '17 at 04:37

0 Answers0