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'");
    $query->execute();
    $count = $query->fetchColumn();
    ;
    if($count==1){
       $_session['username'] =$username;
        $_session['logged_in'] =true;
  header('location: addfile.php');


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

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

        $error = true;

    }


Source: php

Leave a Reply