Are you sure it’s returning any rows?
$stmt->fetchColumn()
is correct way to fetch a single value, so either you probably didn’t bind the :user parameter or it simply returned no rows.
More Related Contents:
- PDOException SQLSTATE[HY000] [2002] No such file or directory
- PDO get the last ID inserted
- PDO mysql: How to know if insert was successful
- MySQL check if a table exists without throwing an exception
- Replacing mysql_* functions with PDO and prepared statements
- PDO::PARAM for type decimal?
- Using LIKE in bindParam for a MySQL PDO Query [duplicate]
- PHP PDO and Mysql [closed]
- Using PHP data in MySQL [closed]
- PHP – Using PDO with IN clause array
- How to properly set up a PDO connection
- PHP PDO prepared statements
- PDO MySQL: Use PDO::ATTR_EMULATE_PREPARES or not?
- strange character encoding of stored data , old script is showing them fine new one doesn’t
- Why I am getting Cannot pass parameter 2 by reference error when I am using bindParam with a constant value?
- mysql PDO how to bind LIKE
- How to loop through a mysql result set
- PHP PDO prepared statement — MySQL LIKE query
- How to get the total number of rows of a GROUP BY query?
- How to connect to mssql using pdo through PHP and Linux?
- How do I loop through a MySQL query via PDO in PHP?
- IP address storing in MySQL database using PHP [duplicate]
- PDO error: SQLSTATE[HY000]: General error: 2031
- Laravel 5.4 on PHP 7.0: PDO Exception – Could not find driver (MySQL)
- How to handle PDO exceptions [duplicate]
- Check if row exists in the database before inserting
- php artisan migrate throwing [PDO Exception] Could not find driver – Using Laravel
- PDO and MySQL Fulltext searches
- mysqli – fetch_Array error call to a member function fetch_array() on a non-object mysqli [duplicate]
- Is a BLOB converted using the current/default charset in MySQL?