I am running the following select statement:
$oid = ("SELECT DISTINCT (MAX(OrderID)) FROM orders WHERE Username = ". $_SESSION['Username'] ." ");
This returns the value of highest Order ID linked to that Username, therefore it being their last order. I want to then run this query:
$Query = "update orders set Status = 'Failed' where Status = 'Success' and where OrderID = ". $oid ." ";
Which will update the orders table, setting the Status to Failed (where it's currently Success).
Why is $oid, returning nothing? If I manually input the values and run it via PHPMyAdmin it works fine.
if (strpos($url,'order-failed') !== false) {
$query = "SELECT DISTINCT (MAX(OrderID)) FROM orders WHERE Username = '". $_SESSION['Username'] ."' ";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
echo $row['OrderID']; // For Debugging
echo "<br /><br />";
$Query = "UPDATE orders SET Status = 'Failed' WHERE Status = 'Success' and OrderID = ". $oid ." ";
$mysqli->query($Query);
echo $Query; // For Debugging
}
The echos return: SELECT DISTINCT (MAX(OrderID)) FROM orders WHERE Username = 'email@email.com' UPDATE orders SET Status = 'Failed' WHERE Status = 'Success' and OrderID =
Order ID is blank! :(