Code: Select all
mysql_result($result, 0, "lesson")edg
Moderator: General Moderators
Code: Select all
mysql_result($result, 0, "lesson")Code: Select all
<?php
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$lesson = $row['lesson'];
?>Code: Select all
<?php
$date = $HTTP_POST_VARS['date'];
$month = $HTTP_POST_VARS['month'];
$year = $HTTP_POST_VARS['year'];
$period = $HTTP_POST_VARS['period'];
$username = $_COOKIE['usercookie'];
$db = mysql_connect("localhost", "blanked", "blanked");
mysql_select_db("test", $db);
$current_epoch = date("U");
$selected_date = date("U", mktime(0,0,0,$month,$date,$year));
if ($current_epoch>$selected_date) {
echo("<strong>Date selected is in the Past.</strong><br /><g5>Unfortunatley, you cannot book a room in the past, please select another date.</g5>");
} else {
$query = "SELECT * FROM booking WHERE day='".$date."' AND month='".$month."' AND year='".$year."' AND lesson='".$period."'";
$result = mysql_query($query, $db);
$row = mysql_fetch_array($result ,MYSQL_ASSOC);
$lesson =$row['lesson'];
echo($lesson);
if ($lesson==$period) {
echo("<strong>Period selected is already booked.</strong><br /><g5>Unfortunatley that period has already been allocated. Please go back and select another.</g5>");
} else {
if ($username != "") {
mysql_query("INSERT INTO booking VALUES ('', '$date', '$month', '$year', '$period', '$username'", $db);
echo("<strong>Booking Entered.</strong><br /><g5>Your booking entry was successful.</g5>");
} else {
echo("<strong>You must be logged in to book a date</strong><br /><g5>It appears you aren't logged in. To Log In <a href="index.php?page=login_form.php">Click Here</a></g5>");
}
}
}
?>Is the problem that you are getting the "Booking Entered" success message, but it's not actually inserting into the database?mysql_query("INSERT INTO booking VALUES ('', '$date', '$month', '$year', '$period', '$username'", $db);
echo("<strong>Booking Entered.</strong><br /><g5>Your booking entry was successful.</g5>");
Code: Select all
<?php
mysql_query("INSERT INTO `booking` (ID, DATE, MONTH, YEAR, PERIOD, USERNAME) VALUES ('', '".$date."', '".$month."', '".$year."', '".$period."', '".$username."'", $db) or die (mysql_error());
?>