PHP/MySQL Prepared statement not assigning a value to a variable?
I have a prepared statement (select with joins) inside my php that seems
to be assigning values to all but one of its variables:
$dbRating = "x";
$dbFavDate = "x";
if($stmt = $dbcon->prepare("
SELECT i.*, u.username, r.rating, f.date_favorited
FROM image i
INNER JOIN user u ON u.uid = ?
LEFT JOIN rating r ON r.iid = ? AND r.uid = ?
LEFT JOIN favorite f ON f.iid = ? AND f.uid = ?
WHERE i.iid = ?")) {
$stmt->bind_param("iiiiii", $qImageOwner, $qImageId, $uid, $qImageId,
$uid, $qImageId);
$stmt->execute();
$stmt->bind_result($dbIid, $dbOwnerUid, $dbTitle, $dbDescription,
$dbFilename, $dbCatid, $dbDateCreated, $dbDateModified,
$dbOwnerUsername, $dbRating, $dbFavDate);
$stmt->fetch();
$stmt->close();
}
I have put this query into phpmyadmin directly and gotten back all
expected values, so I know it's not the sql. I am getting all values
returned as expected except for the $dbFavDate, for some reason this
always displays as 'x' (the initial value I assigned to it before the
query), while the $dbRating which is handled the same way returns the
expected associated rating value. No errors are produced, it seems that
variable is just not being assigned the actual value returned from the
query?
Any help would be greatly appreciated. Thanks, TE
No comments:
Post a Comment