I have a mysql query where i want to only return records that match a userID and I want them ordered by entryID. Here is my code:
function ListAllEntries($dbh, $user)
{
try {
$query = 'SELECT * ' .
'FROM entries ' .
'WHERE userID = :uid' .
'ORDER BY entryID';
$stmt = $dbh->prepare($query);
$stmt->bindParam(':uid', $user);
$stmt->execute();
$entrydata = $stmt->fetchAll(PDO::FETCH_OBJ);
$stmt = null;
return $entrydata;
}
catch(PDOException $e)
{
die ('PDO error getting users pictures": ' . $e->getMessage() );
}
}
When I run this function I get the following error:
Warning: PDOStatement::execute() [pdostatement.execute]: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in
which is followed up by the filename and error location which I obviously won't put here.
I'm not exactly sure what I'm doing wrong here. Any suggestions would be greatly appreciated. Thanks!
P.S. let me know if there is any other details that you need to know.