I have the following code that is supposed to return some records based on lastInsertId() that is stored as a variable. Unfortunately, it's not returning any records when used in the select statements.
ShortageID is an INT data type and the select statement works when I remove the WHERE clause in the select statement. It returns all records, when I just want the record whose ShortageID = $ID.
What's wrong with my syntax?
Thank you in advance.
$query = "
INSERT INTO ShortageDataEntry (
) VALUES (
// Here we prepare our tokens for insertion into the SQL query.
$query_params = array(
':ShortageProduct' => $_POST['ShortageProduct'],
':Quantity' => $_POST['Quantity'],
':userid' => $_SESSION['user']['userid'] ,
':currentdatetime' => $fdate
$stmt = $db->prepare($query);
$result = $stmt->execute($query_params);
$smt = $db->prepare("SELECT ShortageProduct FROM ShortageDataEntry INNER JOIN ShortageProducts ON ShortageDataEntry.ShortageProductID = ShortageProducts.ShortageProductID WHERE ShortageDataEntry.ShortageID = '$ID'");