php - Why does fetchColumn() always return 1?
840
I am confused as to why this always, even when I know it should be 0, returns 1.
function check_user_data($username, $password) {
global $db;
$query = "SELECT COUNT(*) FROM users WHERE username='$username' AND password='$password'";
$results = $db->query($query);
$results = $results->fetchColumn();
echo count($results);
Answer
Solution:
because you are selecting a count in your query which returns a single number and then you are counting that single number with
count($results)
Answer
Solution:
It doesn't.
Check your data and code.