pdo fetchcolumn not working [duplicate]

This question already has an answer here:

hi guys i am making a web application in php but for some reason does $count return nothing i have tried to see if it echo’s a int but it does not here is my code

$query = $pdo->prepare("SELECT COUNT('user_id') FROM 'users' WHERE 'user_name' = '$username' AND WHERE 'password' ='$password'");
    $count = $query->fetchColumn();
       $_session['username'] =$username;
        $_session['logged_in'] =true;
  header('location: addfile.php');

        echo "<p> gegevens kloppen niet</p>";
        echo "<p>$count</p>";

    if(empty($username) || empty($password)){

        $error = true;


Source: php

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.