lundi 30 mars 2015

Mysqli prepared statement working in SQL but not in my application

I'm trying to retrieve the most recent date out of my DB with this:



$stmt2 = $conn->prepare("SELECT reportDate FROM reports WHERE bot=? ORDER BY reportDate DESC LIMIT ?");
$limit = 1;
$stmt2->bind_param("ii", $id, $limit);
$stmt2->execute();
$stmt2->bind_result($lastSeen);


I get the error:



PHP Fatal error: Call to a member function bind_param() on a non-object



I know this usually happens when there's a syntax error in the SQL statement, but I've tried running it in phpmyadmin and it works like a charm. Any suggestion?





Aucun commentaire:

Enregistrer un commentaire