Perhaps I'm missing something very obvious here.
My code doesn't seem to work below the 'GET BOOK ID' annotation if I don't close and reopen the connection.
While it does work, it doesn't seem to be an efficient way at all to do this, any suggestions?
$AddBook = $conn->prepare("CALL makeBooking((SELECT CustID FROM customer WHERE UserName = '$UserName'), ?, ?, ?, ?, now())");
$AddBook->bind_param('iiis',$PerfID, $NumAdults, $NumChilds, $ColTicket);
if ($AddBook->execute())
{
//----------------DEDUCT SEATS--------------//
$SeatDeduction = $conn->prepare("CALL deductSeats($TotalSeats,?)");
$SeatDeduction->bind_param('i',$PerfID);
$SeatDeduction->execute();
mysqli_close($conn);
require ('connect.php');
//-----------------GET BOOK ID--------------//
$getBookID = "CALL getBookByUserName('$UserName')";
$result2 = mysqli_query($conn, $getBookID);
$Output2 = mysqli_fetch_assoc($result2);
$BookID = $Output2['BookID'];
mysqli_close($conn);
require ('connect.php');
//-------------------SET COST---------------//
$setCost = "CALL setBookingPrice($BookID)";
mysqli_query($conn,$setCost);
mysqli_close($conn);
require ('connect.php');
//-------------------GET COST---------------//
$getCost = "CALL getCost($BookID)";
$result6 = mysqli_query($conn,$getCost);
$Output6 = mysqli_fetch_assoc($result6);
$Cost = $Output6['TotalCost'];
mysqli_close($conn);
require ('connect.php');
//---------------BOOKING CONFIRM------------//
$ShowRef = 'Booking Completed<p>Reference Number: <b>' . $BookID . '</b><p>';
$showCost = 'Total Cost: <b><u>£' . $Cost . '<u><b><br>';
$Confirm = $ShowRef.$showCost;
}
else
{
die(mysqli_error($conn));
}
mysqli_close($conn);