Use PDO
like this, PDO
and mysql_*
functions not working together, you have to use them separately
$sth = $dbh->prepare('SELECT COUNT(username) FROM users
WHERE username= :username GROUP BY username');
$sth->bindParam(':username', $username, PDO::PARAM_STR);
$sth->execute();
if ($sth->fetchColumn() > 0) {
echo "username taken";
}
2
solved PHP check for existing entry in database [closed]