I have this code which should update the domainReserved row to 0 from 1, after the payment is made, inserted in database with status approved.
if (isset($_SESSION["cart"])) {
foreach ($_SESSION["cart"] as $key => $value) {
foreach ($_SESSION["cart"][$key] as $domain) {
$registered = 0;
$reserved = 1;
$updateDomainSQL = "UPDATE domains SET domainReserved = ? WHERE domainName = ? AND domainReserved = ?";
$updateStmt = $dbConn->prepare($updateDomainSQL);
$updateStmt->bind_param('isi', $registered, $domain, $reserved);
}
}
}
The problem with this code is that the row is not updated. I want to mention that the domainReserved row is saved as an ENUM with 0 and 1 values.
Before using the code above, I had the code down below which sent me a message that said the code was executed, but there was no update in the database:
$updateDomainSQL = "UPDATE domains SET domainReserved = 0 WHERE domainName = '$domain'";
if (isset($_SESSION["cart"])) {
foreach ($_SESSION["cart"] as $key => $value) {
foreach ($_SESSION["cart"][$key] as $domain) {
$updateDomainSQL = "UPDATE domains SET domainReserved = 0 WHERE domainName = '$domain'";
if ($updateStmt = mysqli_prepare($dbConn, $updateDomainSQL)) {
if (mysqli_stmt_execute($updateStmt)) {
echo "executed: " . $updateDomainSQL . "<br />";
} else {
echo "ERROR: Could not execute query: $insertDomainSQL. " . mysqli_error($dbConn);
}
mysqli_stmt_close($updateStmt);
}
}
}
}