Could someone please tell me what is wrong with my code. When I try to use the function, I get:
Fatal error: Call to a member function setFetchMode() on a non-object in ...
Using:
if (!$IDq) { print_r($dbh->errorInfo()); }
gives me: file is encrypted or is not a database
I have been messing with it for ages but can't seem to get it to work.
function user_registered($user_id){
$dbh = new PDO("sqlite:datastore/userids.db");
$IDq = $dbh->query("SELECT * FROM users_identify WHERE identifier = '$user_id'");
$IDq->setFetchMode(PDO::FETCH_ASSOC);
$IDf = $IDq->fetch();
if($IDf['id']){
return $IDf['id'];
}else{
return 0;
}
}
Thanks.
EDIT: Ah, thanks for your help. I found the problem, it was that I was using an sqlite 2 database when I needed an sqlite 3 database.