I get this error from the following code. I have tried various things. Cannot understand why it is saying it is not defined. I have put the variables on different lines to identify which one is the problem and the error always follows the line where the propID
= :propertyID is. I have an echo statement showing what is set to $propyID and it comes out correct each time I run the code but then says the variable is not defined.
$exist = "SELECT `propID` FROM `custAdr`
WHERE `streetAdr` = :street and `zip` = :zip";
$stmt = $connect->prepare($exist);
$stmt->execute(array(
'street' => $street,
'zip' => $zip,
));
$data = $stmt->fetchAll();
$propyID = $data[0]['propID'];
echo $propyID; //shows correct result
$sql = "UPDATE `custAdr` SET `altCustID` = :custId WHERE `propID` = :propertyID";
$stmt = $connect->prepare($sql);
$stmt->execute(['custID' => $custID, 'propertyID' => $propyID,]);
//Error shows that $propyID is not set even though I have verified it