checking is username exists on two tables PHP PDO?
- by PHPLOVER
Me again.
I have a users table and a users_banlist table.
On my registration form i want to check all in one query whether the username someone entered on form exists in the users table and see if it also exists on the users_banlist table.
I can do them on there own in individual queries but would rather do it all in one.
Here is what i got, but even thou i enter a username that is taken it does not tell me its already taken.
$stmt = $dbh->prepare("
SELECT
users.user_login,
users_banlist.user_banlist
FROM
users ,
users_banlist
WHERE
users.user_login = ? OR
users_banlist.user_banlist = ?");
// checker if username exists in users table or users_banlist table
$stmt->execute(array($username, $username));
if ( $stmt->rowCount() > 0 ) {
$error[] = 'Username already taken';
}
Basically i think it is something to do with the execute or rowCount(), could anyone tell me where i am going wrong ? being new to pdo im finding it a little confusing at the moment until i get my pdo book delivered to learn pdo.
Thank you as always,
phplover