Hello,
I've come upon a rather interesting thing, which I can't seem to figure out myself.
Everytime when executing a SQL statement which contains a '... AND ...' the result is empty.
Example:
echo('I have a user: ' . $email . $wachtwoord . '<br>');
$dbh = new PDO($dsn, $user, $password);
$sql = 'SELECT * FROM user WHERE email = :email AND wachtwoord= :wachtwoord';
$stmt = $dbh->prepare($sql);
$stmt->bindParam(:email,$email,PDO::PARAM_STR);
$stmt->bindParam(:wachtwoord,$wachtwoord,PDO::PARAM_STR);
$stmt->execute();
while($row = $stmt->fetchObject())
{
echo($row-email . ',' . $row-wachtwoord);
$user[] = array(
'email' = $row-email,
'wachtwoord' = $row-wachtwoord
);
}
The first echo displays the correct values, however the line with
echo($row->email . ',' . $row->wachtwoord);
is never reached.
A few things I want to add:
1) I am connected to the database since other queries work, only the ones where I add an 'AND' after my 'WHERE's fail.
2) Working with the while works perfectly with queries that do not contain '... AND ...'
3) Error reporting is on,
PDO gives no exceptions on my query (or anything else)
4) Executing the query directly on the database does give what I want:
SELECT * FROM user WHERE email = '
[email protected]' AND wachtwoord = 'jurgen'
I can stare at it all day long again (which I already did once, but I managed to work around the 'AND'), but maybe one of you can give me a helping hand.
Thank you in advance.
Jurgen