will_1990 Posted December 11, 2008 Share Posted December 11, 2008 I noticed that i cannot compare two english dates with strtotime i have to convert them to us and then store them as time stamps. i think this what i have done here. Any help would be great. <?php // Variables $flight_route_out = $_POST['flight_route_out']; $flight_route_return = $_POST['flight_route_return']; $date_out = $_POST['departure_date']; $date_return = $_POST['return_date']; $passenger_num = $_POST['num_of_pass']; $one_way = (isset($_POST['one_way'])) ? $_POST['one_way'] : null; // make sure value is available first. $nonUSdate1 = $date_out; list($day,$month,$year) = explode('/',$nonUSdate1); $newDate = "{$month}/{$day}/{$year}"; $stamp = strtotime($newDate1); $nonUSdate2 = $date_return; list($day,$month,$year) = explode('/',$nonUSdate2); $newDate = "{$month}/{$day}/{$year}"; $stamp = strtotime($newDate2); //To protect MySQL injection $flight_route_out = stripslashes($flight_route_out); $flight_route_return = stripslashes($flight_route_return); $flight_route_out = mysql_real_escape_string($flight_route_out); $flight_route_return = mysql_real_escape_string($flight_route_return); //Queries $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'"; //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'"; //Execute query 1 $result = mysql_query($sql1) or die(mysql_error()); if $newDate2 < $newDate2 { echo "You cannot return before you leave!"; thanks alot. edit just noticed that i had two $stamp variables.. dont think this is the problem as its stopping me getting any output. thanks Quote Link to comment https://forums.phpfreaks.com/topic/136553-what-is-wrong-with-my-date-comparison-structure/ Share on other sites More sharing options...
will_1990 Posted December 11, 2008 Author Share Posted December 11, 2008 latest updated code: <?php // Variables $flight_route_out = $_POST['flight_route_out']; $flight_route_return = $_POST['flight_route_return']; $date_out = $_POST['departure_date']; $date_return = $_POST['return_date']; $passenger_num = $_POST['num_of_pass']; $one_way = (isset($_POST['one_way'])) ? $_POST['one_way'] : null; // make sure value is available first. $nonUSdate1 = $date_out; list($day,$month,$year) = explode('/',$nonUSdate1); $newDate1 = "{$month}/{$day}/{$year}"; $stamp1 = strtotime($newDate1); $nonUSdate2 = $date_return; list($day,$month,$year) = explode('/',$nonUSdate2); $newDate2 = "{$month}/{$day}/{$year}"; $stamp2 = strtotime($newDate2); //To protect MySQL injection $flight_route_out = stripslashes($flight_route_out); $flight_route_return = stripslashes($flight_route_return); $flight_route_out = mysql_real_escape_string($flight_route_out); $flight_route_return = mysql_real_escape_string($flight_route_return); //Queries $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'"; //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'"; //Execute query 1 $result = mysql_query($sql1) or die(mysql_error()); if $newDate2 < $newDate1 { echo "You cannot return before you leave!"; Quote Link to comment https://forums.phpfreaks.com/topic/136553-what-is-wrong-with-my-date-comparison-structure/#findComment-712790 Share on other sites More sharing options...
Maq Posted December 11, 2008 Share Posted December 11, 2008 Instead of: $nonUSdate1 = $date_out; list($day,$month,$year) = explode('/',$nonUSdate1); $newDate1 = "{$month}/{$day}/{$year}"; $stamp1 = strtotime($newDate1); Why can't you just do something like: $stamp1 = strtotime($date_out); Quote Link to comment https://forums.phpfreaks.com/topic/136553-what-is-wrong-with-my-date-comparison-structure/#findComment-712798 Share on other sites More sharing options...
will_1990 Posted December 11, 2008 Author Share Posted December 11, 2008 Instead of: $nonUSdate1 = $date_out; list($day,$month,$year) = explode('/',$nonUSdate1); $newDate1 = "{$month}/{$day}/{$year}"; $stamp1 = strtotime($newDate1); Why can't you just do something like: $stamp1 = strtotime($date_out); because i read it didnt work with uk dates such as dd/mm/yyyy? am i incorrect? Quote Link to comment https://forums.phpfreaks.com/topic/136553-what-is-wrong-with-my-date-comparison-structure/#findComment-712803 Share on other sites More sharing options...
Maq Posted December 11, 2008 Share Posted December 11, 2008 I don't think it matters what format the date is in. The strtotime() function handles every "normal" date format and returns a timestamp, at least to my knowledge. Try it out! Quote Link to comment https://forums.phpfreaks.com/topic/136553-what-is-wrong-with-my-date-comparison-structure/#findComment-712808 Share on other sites More sharing options...
will_1990 Posted December 11, 2008 Author Share Posted December 11, 2008 I don't think it matters what format the date is in. The strtotime() function handles every "normal" date format and returns a timestamp, at least to my knowledge. Try it out! Tried it with this coding: <?php $stamp1 = strtotime($date_out); $stamp2 = strtotime($date_return); //To protect MySQL injection $flight_route_out = stripslashes($flight_route_out); $flight_route_return = stripslashes($flight_route_return); $flight_route_out = mysql_real_escape_string($flight_route_out); $flight_route_return = mysql_real_escape_string($flight_route_return); //Queries $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'"; //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'"; //Execute query 1 $result = mysql_query($sql1) or die(mysql_error()); if ($stamp2 < $stamp1) { echo "You cannot book a return flight before your out-going flight!"; } it is now returning the following page and extrating the information from the database. But this happens even when the return date <departure date its ignoring the echo "blah blah blah"; any ideas> Quote Link to comment https://forums.phpfreaks.com/topic/136553-what-is-wrong-with-my-date-comparison-structure/#findComment-712824 Share on other sites More sharing options...
Maq Posted December 11, 2008 Share Posted December 11, 2008 I just did a test and it works. Assuming that the user types/chooses dates in the following format- dd/mm/yyy. //$date_out = "11/12/2008"; //$date_return = "11/11/2008"; //echos out the error $date_out = "11/09/2008"; $date_return = "11/11/2008"; //echoes out have fun on your trip!! $stamp1 = strtotime($date_out); $stamp2 = strtotime($date_return); if($stamp2 { echo "You cannot book a return flight before your out-going flight!"; } else { echo "have fun on your trip!"; } I'm not sure what you're doing wrong. I will take another look at your script. Quote Link to comment https://forums.phpfreaks.com/topic/136553-what-is-wrong-with-my-date-comparison-structure/#findComment-712847 Share on other sites More sharing options...
will_1990 Posted December 11, 2008 Author Share Posted December 11, 2008 I just did a test and it works. Assuming that the user types/chooses dates in the following format- dd/mm/yyy. //$date_out = "11/12/2008"; //$date_return = "11/11/2008"; //echos out the error $date_out = "11/09/2008"; $date_return = "11/11/2008"; //echoes out have fun on your trip!! $stamp1 = strtotime($date_out); $stamp2 = strtotime($date_return); if($stamp2 < $stamp1) { echo "You cannot book a return flight before your out-going flight!"; } else { echo "have fun on your trip!"; } I'm not sure what you're doing wrong. I will take another look at your script. that looks exactly like what i have apart from its using $date_out instead of 11/09/2008 (but technically that is what it would be like once it is entered into the booking table) i will post my whole code as there is alot more than just have a good holiday. here it is sorry for the amount, i dont expect you to even look at most of it <?php //database information $host = "stocks"; // Host name $username = "wbennett"; // Mysql username $password = "mysql5"; // Mysql password $db_name = "wbennett"; // Database name $tbl_name1 = "flight_webair"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Variables $flight_route_out = $_POST['flight_route_out']; $flight_route_return = $_POST['flight_route_return']; $date_out = $_POST['departure_date']; $date_return = $_POST['return_date']; $passenger_num = $_POST['num_of_pass']; $one_way = (isset($_POST['one_way'])) ? $_POST['one_way'] : null; // make sure value is available first. $stamp1 = strtotime($date_out); $stamp2 = strtotime($date_return); //To protect MySQL injection $flight_route_out = stripslashes($flight_route_out); $flight_route_return = stripslashes($flight_route_return); $flight_route_out = mysql_real_escape_string($flight_route_out); $flight_route_return = mysql_real_escape_string($flight_route_return); //Queries $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'"; //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'"; //Execute query 1 $result = mysql_query($sql1) or die(mysql_error()); if ($stamp2 < $stamp1) { echo "You cannot book a return flight before your out-going flight!"; } if(mysql_num_rows($result) > 0){ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" href="dropdown2.css" type="text/css" /> <script type="text/javascript" src="dropdown.js"> </script> <script type="text/javascript" src="calendar.js"> </script> <script type="text/javascript" src="enablefield.js"> </script> <title> Booking Confirmation </title> <script type="text/javascript"> function greyText(one_way, return_date) { if (document.form1[one_way].checked) { document.form1[return_date].disabled=true; document.form1[return_flight].disabled=true; } else { document.form1[return_date].disabled=false; document.form1[return_flight].disabled=false; } } <title>Webair Contact Us</title> <link rel="StyleSheet" href="./mainstyle.css"type="text/css" media="screen"> </script> </head> <body> <div id="wrapper"> <table> <tr> <td> <img src="Webair--logo.gif" height= "65" width="240" align="top" /> </td> <td background="Banner--background.gif" height="60" align="right" width="817" > <a class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/main_logon.php"> <b> Staff login </b> </a> | <a class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" > <b> Home </b> </a> | <a class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" > <b> Booked Flights   </b> </a> </td> </tr> </table> <dl class="dropdown" > <dt id="one-ddheader" onmouseover="ddMenu('one',1)" onmouseout="ddMenu('one',-1)" > Home </dt> <dd id="one-ddcontent" onmouseover="cancelHide('one')" onmouseout="ddMenu('one',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" class="underline" > Home </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="two-ddheader" onmouseover="ddMenu('two',1)" onmouseout="ddMenu('two',-1)" > Contact us </dt> <dd id="two-ddcontent" onmouseover="cancelHide('two')" onmouseout="ddMenu('two',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact" class="underline" > Contact us </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="three-ddheader" onmouseover="ddMenu('three',1)" onmouseout="ddMenu('three',-1)" > Flights </dt> <dd id="three-ddcontent" onmouseover="cancelHide('three')" onmouseout="ddMenu('three',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_refunds.html" class="underline" > Refund Policy </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="four-ddheader" onmouseover="ddMenu('four',1)" onmouseout="ddMenu('four',-1)" > Travel Information </dt> <dd id="four-ddcontent" onmouseover="cancelHide('four')" onmouseout="ddMenu('four',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_flight_fares.html" class="underline" > Flight Timetable </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_baggage.html" class="underline" > Baggage Information </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_airport_info.html" class="underline" > Airport information </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_travel_info.html" class="underline" > Travel documentation requirements </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="five-ddheader" onmouseover="ddMenu('five',1)" onmouseout="ddMenu('five',-1)" > About Webair </dt> <dd id="five-ddcontent" onmouseover="cancelHide('five')" onmouseout="ddMenu('five',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_about.html" class="underline" > About Webair </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact.html" class="underline" > Contact us </a> </li> </ul> </dd> </dl> <div style="clear:both" /> </div> <div id="content" > <div id="table_gen_1" > <div class="inner" > <br> <h1><center> Confirm Booking </center></h1> <h3><b><u> Out-going Flight Information: </u></b></h3> <?php while($row = mysql_fetch_array($result)){ echo " <br><br> <table border='1' cellpadding=10> <tr> <td class='table'> <center><b> Flight Number </b></center> </td> <td class='table'> <center><b> Flight Route Selected </b></center> </td> <td class='table'> <center><b> Departure Time </b> </center> </td> <td class='table'> <center><b> Arrival Time </b></center> </td> <td class='table'> <center><b> Departure Date </b></center> </td> <td class='table'> <center><b> Return Date </b></center> </td> <td class='table'> <center><b> Number of Passengers Selected </b></center> </td> </tr> <tr> <td class='table'> <center> ".$row['flight_num']." </center> </td> <td class='table'> <center> ".$row['flight_route']." </center> </td> <td class='table'> <center> ".$row['departure_time']." </center> </td> <td class='table'> <center> ".$row['arrival_time']." </center> </td> <td class='table'> <center> ".$date_out." </center> </td> <td class='table'> <center> ".$date_return." </center> </td> <td class='table'> <center> ".$passenger_num['num_of_pass']." </center> </td> </tr> </table> <br><br>"; } ?> </div> </div> </div> <div id="footer"> <div id="inner"> <div id="footer2"> <p><hr class="line"></hr> <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/main_logon.php"><b>Staff login</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html"><b>Home</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact.html"><b>Contact us</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_about.html"><b>About Webair</b></a> <hr class="line2"></hr> </p> </div> </div> </div> </body> </html> <?php }else{ echo 'Sorry, couldn\'t find any flights'; } mysql_free_result($result); ?> Quote Link to comment https://forums.phpfreaks.com/topic/136553-what-is-wrong-with-my-date-comparison-structure/#findComment-712857 Share on other sites More sharing options...
Maq Posted December 11, 2008 Share Posted December 11, 2008 Can you print out your vars to make sure they have values? Also, put die in instead of echo for the second line. Post the output for these lines: echo " ".$_POST['departure_date']." ".$_POST['return_date']." ".$stamp1." ".$stamp2." "; die("You cannot book a return flight before your out-going flight!"); Quote Link to comment https://forums.phpfreaks.com/topic/136553-what-is-wrong-with-my-date-comparison-structure/#findComment-712879 Share on other sites More sharing options...
will_1990 Posted December 11, 2008 Author Share Posted December 11, 2008 Can you print out your vars to make sure they have values? Also, put die in instead of echo for the second line. Post the output for these lines: echo "<br /> ".$_POST['departure_date']."<br /> ".$_POST['return_date']."<br /> ".$stamp1."<br /> ".$stamp2."<br /> "; die("You cannot book a return flight before your out-going flight!"); I replaced the echo line with the ech br $_POST... but it just continues down the script and outputs the table with the return date earlier than the out going date, do you what a print screen or anything? thanks Quote Link to comment https://forums.phpfreaks.com/topic/136553-what-is-wrong-with-my-date-comparison-structure/#findComment-712931 Share on other sites More sharing options...
Maq Posted December 11, 2008 Share Posted December 11, 2008 It's supposed to print to screen. The output should be at the very top of the page if there were any values. At the very top of your script, right after the <?php tags, put: print_r($_POST); This will dump out the $_POST array with all the values, if there are any. Quote Link to comment https://forums.phpfreaks.com/topic/136553-what-is-wrong-with-my-date-comparison-structure/#findComment-712942 Share on other sites More sharing options...
will_1990 Posted December 11, 2008 Author Share Posted December 11, 2008 It's supposed to print to screen. The output should be at the very top of the page if there were any values. At the very top of your script, right after the <?php tags, put: print_r($_POST); This will dump out the $_POST array with all the values, if there are any. Here are the results, Array ( [flight_route_out] => Bristol - Newcastle [departure_date] => 26/12/2008 [flight_route_return] => Bristol - Newcastle [return_date] => 22/12/2008 [num_of_pass] => 1 [submit] => Submit ) it all looks ok to me, printing the variables fine... Quote Link to comment https://forums.phpfreaks.com/topic/136553-what-is-wrong-with-my-date-comparison-structure/#findComment-712955 Share on other sites More sharing options...
Maq Posted December 11, 2008 Share Posted December 11, 2008 Take out the stamp variables and try this: if (strtotime($_POST['return_date']) echo "You cannot book a return flight before your out-going flight!"; } else { echo "You cannot book a return flight before your out-going flight!"; } Quote Link to comment https://forums.phpfreaks.com/topic/136553-what-is-wrong-with-my-date-comparison-structure/#findComment-712963 Share on other sites More sharing options...
will_1990 Posted December 11, 2008 Author Share Posted December 11, 2008 Maq here is the output, i left the print_r in: Array ( [flight_route_out] => Bristol - Newcastle [departure_date] => 26/12/2008 [flight_route_return] => Bristol - Newcastle [return_date] => 22/12/2008 [num_of_pass] => 1 [submit] => Submit ) You cannot book a return flight before your out-going flight! but then it also continued with my layout that i have later and also with my while loop. which continues to display all the data from the database and the dates etc... Quote Link to comment https://forums.phpfreaks.com/topic/136553-what-is-wrong-with-my-date-comparison-structure/#findComment-712983 Share on other sites More sharing options...
will_1990 Posted December 11, 2008 Author Share Posted December 11, 2008 does this mean its continueing with my loop dispite the die commmand? Quote Link to comment https://forums.phpfreaks.com/topic/136553-what-is-wrong-with-my-date-comparison-structure/#findComment-712993 Share on other sites More sharing options...
Maq Posted December 11, 2008 Share Posted December 11, 2008 Well at least the date check works because 22/12/2008 (return) is before 26/12/2008 (departure). but then it also continued with my layout that i have later and also with my while loop. What do you mean? Do you have a link/screenshot so I can see what's going on? The while loop is no where near the echo. Quote Link to comment https://forums.phpfreaks.com/topic/136553-what-is-wrong-with-my-date-comparison-structure/#findComment-712996 Share on other sites More sharing options...
Maq Posted December 11, 2008 Share Posted December 11, 2008 Post ALL of your current code. Quote Link to comment https://forums.phpfreaks.com/topic/136553-what-is-wrong-with-my-date-comparison-structure/#findComment-713003 Share on other sites More sharing options...
will_1990 Posted December 11, 2008 Author Share Posted December 11, 2008 Post ALL of your current code. <?php print_r($_POST); //database information $host = "stocks"; // Host name $username = "wbennett"; // Mysql username $password = "mysql5"; // Mysql password $db_name = "wbennett"; // Database name $tbl_name1 = "flight_webair"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Variables $flight_route_out = $_POST['flight_route_out']; $flight_route_return = $_POST['flight_route_return']; $date_out = $_POST['departure_date']; $date_return = $_POST['return_date']; $passenger_num = $_POST['num_of_pass']; $one_way = (isset($_POST['one_way'])) ? $_POST['one_way'] : null; // make sure value is available first. if (strtotime($_POST['return_date']) < strtotime($_POST['departure_date'])) { echo "You cannot book a return flight before your out-going flight!"; } else { echo "You cannot book a return flight before your out-going flight!"; } //To protect MySQL injection $flight_route_out = stripslashes($flight_route_out); $flight_route_return = stripslashes($flight_route_return); $flight_route_out = mysql_real_escape_string($flight_route_out); $flight_route_return = mysql_real_escape_string($flight_route_return); //Queries $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'"; //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'"; //Execute query 1 $result = mysql_query($sql1) or die(mysql_error()); if(mysql_num_rows($result) > 0){ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" href="dropdown2.css" type="text/css" /> <script type="text/javascript" src="dropdown.js"> </script> <script type="text/javascript" src="calendar.js"> </script> <script type="text/javascript" src="enablefield.js"> </script> <title> Booking Confirmation </title> <script type="text/javascript"> function greyText(one_way, return_date) { if (document.form1[one_way].checked) { document.form1[return_date].disabled=true; document.form1[return_flight].disabled=true; } else { document.form1[return_date].disabled=false; document.form1[return_flight].disabled=false; } } <title>Webair Contact Us</title> <link rel="StyleSheet" href="./mainstyle.css"type="text/css" media="screen"> </script> </head> <body> <div id="wrapper"> <table> <tr> <td> <img src="Webair--logo.gif" height= "65" width="240" align="top" /> </td> <td background="Banner--background.gif" height="60" align="right" width="817" > <a class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/main_logon.php"> <b> Staff login </b> </a> | <a class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" > <b> Home </b> </a> | <a class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" > <b> Booked Flights   </b> </a> </td> </tr> </table> <dl class="dropdown" > <dt id="one-ddheader" onmouseover="ddMenu('one',1)" onmouseout="ddMenu('one',-1)" > Home </dt> <dd id="one-ddcontent" onmouseover="cancelHide('one')" onmouseout="ddMenu('one',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" class="underline" > Home </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="two-ddheader" onmouseover="ddMenu('two',1)" onmouseout="ddMenu('two',-1)" > Contact us </dt> <dd id="two-ddcontent" onmouseover="cancelHide('two')" onmouseout="ddMenu('two',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact" class="underline" > Contact us </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="three-ddheader" onmouseover="ddMenu('three',1)" onmouseout="ddMenu('three',-1)" > Flights </dt> <dd id="three-ddcontent" onmouseover="cancelHide('three')" onmouseout="ddMenu('three',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_refunds.html" class="underline" > Refund Policy </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="four-ddheader" onmouseover="ddMenu('four',1)" onmouseout="ddMenu('four',-1)" > Travel Information </dt> <dd id="four-ddcontent" onmouseover="cancelHide('four')" onmouseout="ddMenu('four',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_flight_fares.html" class="underline" > Flight Timetable </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_baggage.html" class="underline" > Baggage Information </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_airport_info.html" class="underline" > Airport information </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_travel_info.html" class="underline" > Travel documentation requirements </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="five-ddheader" onmouseover="ddMenu('five',1)" onmouseout="ddMenu('five',-1)" > About Webair </dt> <dd id="five-ddcontent" onmouseover="cancelHide('five')" onmouseout="ddMenu('five',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_about.html" class="underline" > About Webair </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact.html" class="underline" > Contact us </a> </li> </ul> </dd> </dl> <div style="clear:both" /> </div> <div id="content" > <div id="table_gen_1" > <div class="inner" > <br> <h1><center> Confirm Booking </center></h1> <h3><b><u> Out-going Flight Information: </u></b></h3> <?php while($row = mysql_fetch_array($result)){ echo " <br><br> <table border='1' cellpadding=10> <tr> <td class='table'> <center><b> Flight Number </b></center> </td> <td class='table'> <center><b> Flight Route Selected </b></center> </td> <td class='table'> <center><b> Departure Time </b> </center> </td> <td class='table'> <center><b> Arrival Time </b></center> </td> <td class='table'> <center><b> Departure Date </b></center> </td> <td class='table'> <center><b> Return Date </b></center> </td> <td class='table'> <center><b> Number of Passengers Selected </b></center> </td> </tr> <tr> <td class='table'> <center> ".$row['flight_num']." </center> </td> <td class='table'> <center> ".$row['flight_route']." </center> </td> <td class='table'> <center> ".$row['departure_time']." </center> </td> <td class='table'> <center> ".$row['arrival_time']." </center> </td> <td class='table'> <center> ".$date_out." </center> </td> <td class='table'> <center> ".$date_return." </center> </td> <td class='table'> <center> ".$passenger_num['num_of_pass']." </center> </td> </tr> </table> <br><br>"; } ?> </div> </div> </div> <div id="footer"> <div id="inner"> <div id="footer2"> <p><hr class="line"></hr> <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/main_logon.php"><b>Staff login</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html"><b>Home</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact.html"><b>Contact us</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_about.html"><b>About Webair</b></a> <hr class="line2"></hr> </p> </div> </div> </div> </body> </html> <?php }else{ echo 'Sorry, couldn\'t find any flights'; } mysql_free_result($result); ?> screen shot comming Quote Link to comment https://forums.phpfreaks.com/topic/136553-what-is-wrong-with-my-date-comparison-structure/#findComment-713008 Share on other sites More sharing options...
will_1990 Posted December 11, 2008 Author Share Posted December 11, 2008 Post ALL of your current code. <?php print_r($_POST); //database information $host = "stocks"; // Host name $username = "wbennett"; // Mysql username $password = "mysql5"; // Mysql password $db_name = "wbennett"; // Database name $tbl_name1 = "flight_webair"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Variables $flight_route_out = $_POST['flight_route_out']; $flight_route_return = $_POST['flight_route_return']; $date_out = $_POST['departure_date']; $date_return = $_POST['return_date']; $passenger_num = $_POST['num_of_pass']; $one_way = (isset($_POST['one_way'])) ? $_POST['one_way'] : null; // make sure value is available first. if (strtotime($_POST['return_date']) < strtotime($_POST['departure_date'])) { echo "You cannot book a return flight before your out-going flight!"; } else { echo "You cannot book a return flight before your out-going flight!"; } //To protect MySQL injection $flight_route_out = stripslashes($flight_route_out); $flight_route_return = stripslashes($flight_route_return); $flight_route_out = mysql_real_escape_string($flight_route_out); $flight_route_return = mysql_real_escape_string($flight_route_return); //Queries $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'"; //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'"; //Execute query 1 $result = mysql_query($sql1) or die(mysql_error()); if(mysql_num_rows($result) > 0){ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" href="dropdown2.css" type="text/css" /> <script type="text/javascript" src="dropdown.js"> </script> <script type="text/javascript" src="calendar.js"> </script> <script type="text/javascript" src="enablefield.js"> </script> <title> Booking Confirmation </title> <script type="text/javascript"> function greyText(one_way, return_date) { if (document.form1[one_way].checked) { document.form1[return_date].disabled=true; document.form1[return_flight].disabled=true; } else { document.form1[return_date].disabled=false; document.form1[return_flight].disabled=false; } } <title>Webair Contact Us</title> <link rel="StyleSheet" href="./mainstyle.css"type="text/css" media="screen"> </script> </head> <body> <div id="wrapper"> <table> <tr> <td> <img src="Webair--logo.gif" height= "65" width="240" align="top" /> </td> <td background="Banner--background.gif" height="60" align="right" width="817" > <a class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/main_logon.php"> <b> Staff login </b> </a> | <a class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" > <b> Home </b> </a> | <a class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" > <b> Booked Flights   </b> </a> </td> </tr> </table> <dl class="dropdown" > <dt id="one-ddheader" onmouseover="ddMenu('one',1)" onmouseout="ddMenu('one',-1)" > Home </dt> <dd id="one-ddcontent" onmouseover="cancelHide('one')" onmouseout="ddMenu('one',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" class="underline" > Home </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="two-ddheader" onmouseover="ddMenu('two',1)" onmouseout="ddMenu('two',-1)" > Contact us </dt> <dd id="two-ddcontent" onmouseover="cancelHide('two')" onmouseout="ddMenu('two',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact" class="underline" > Contact us </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="three-ddheader" onmouseover="ddMenu('three',1)" onmouseout="ddMenu('three',-1)" > Flights </dt> <dd id="three-ddcontent" onmouseover="cancelHide('three')" onmouseout="ddMenu('three',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_refunds.html" class="underline" > Refund Policy </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="four-ddheader" onmouseover="ddMenu('four',1)" onmouseout="ddMenu('four',-1)" > Travel Information </dt> <dd id="four-ddcontent" onmouseover="cancelHide('four')" onmouseout="ddMenu('four',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_flight_fares.html" class="underline" > Flight Timetable </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_baggage.html" class="underline" > Baggage Information </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_airport_info.html" class="underline" > Airport information </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_travel_info.html" class="underline" > Travel documentation requirements </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="five-ddheader" onmouseover="ddMenu('five',1)" onmouseout="ddMenu('five',-1)" > About Webair </dt> <dd id="five-ddcontent" onmouseover="cancelHide('five')" onmouseout="ddMenu('five',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_about.html" class="underline" > About Webair </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact.html" class="underline" > Contact us </a> </li> </ul> </dd> </dl> <div style="clear:both" /> </div> <div id="content" > <div id="table_gen_1" > <div class="inner" > <br> <h1><center> Confirm Booking </center></h1> <h3><b><u> Out-going Flight Information: </u></b></h3> <?php while($row = mysql_fetch_array($result)){ echo " <br><br> <table border='1' cellpadding=10> <tr> <td class='table'> <center><b> Flight Number </b></center> </td> <td class='table'> <center><b> Flight Route Selected </b></center> </td> <td class='table'> <center><b> Departure Time </b> </center> </td> <td class='table'> <center><b> Arrival Time </b></center> </td> <td class='table'> <center><b> Departure Date </b></center> </td> <td class='table'> <center><b> Return Date </b></center> </td> <td class='table'> <center><b> Number of Passengers Selected </b></center> </td> </tr> <tr> <td class='table'> <center> ".$row['flight_num']." </center> </td> <td class='table'> <center> ".$row['flight_route']." </center> </td> <td class='table'> <center> ".$row['departure_time']." </center> </td> <td class='table'> <center> ".$row['arrival_time']." </center> </td> <td class='table'> <center> ".$date_out." </center> </td> <td class='table'> <center> ".$date_return." </center> </td> <td class='table'> <center> ".$passenger_num['num_of_pass']." </center> </td> </tr> </table> <br><br>"; } ?> </div> </div> </div> <div id="footer"> <div id="inner"> <div id="footer2"> <p><hr class="line"></hr> <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/main_logon.php"><b>Staff login</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html"><b>Home</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact.html"><b>Contact us</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_about.html"><b>About Webair</b></a> <hr class="line2"></hr> </p> </div> </div> </div> </body> </html> <?php }else{ echo 'Sorry, couldn\'t find any flights'; } mysql_free_result($result); ?> screen shot comming http://img179.imageshack.us/my.php?image=latestaz2.jpg Quote Link to comment https://forums.phpfreaks.com/topic/136553-what-is-wrong-with-my-date-comparison-structure/#findComment-713012 Share on other sites More sharing options...
Maq Posted December 11, 2008 Share Posted December 11, 2008 Oh ok I see what you mean. You need to have flags that determine if there are errors or not. You should really have an include file for your header and footer. Try this code: $error = FALSE; //database information $host = "stocks"; // Host name $username = "wbennett"; // Mysql username $password = "mysql5"; // Mysql password $db_name = "wbennett"; // Database name $tbl_name1 = "flight_webair"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Variables $flight_route_out = $_POST['flight_route_out']; $flight_route_return = $_POST['flight_route_return']; $date_out = $_POST['departure_date']; $date_return = $_POST['return_date']; $passenger_num = $_POST['num_of_pass']; $one_way = (isset($_POST['one_way'])) ? $_POST['one_way'] : null; // make sure value is available first. if (strtotime($_POST['return_date']) $output = "You cannot book a return flight before your out-going flight!"; $error = TRUE; } else { $output = "You cannot book a return flight before your out-going flight!"; } //To protect MySQL injection $flight_route_out = stripslashes($flight_route_out); $flight_route_return = stripslashes($flight_route_return); $flight_route_out = mysql_real_escape_string($flight_route_out); $flight_route_return = mysql_real_escape_string($flight_route_return); //Queries $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'"; //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'"; //Execute query 1 $result = mysql_query($sql1) or die(mysql_error()); if(mysql_num_rows($result) > 0){ ?> http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> rel="stylesheet" href="dropdown2.css" type="text/css" /> type="text/javascript" src="dropdown.js"> type="text/javascript" src="calendar.js"> type="text/javascript" src="enablefield.js"> Booking Confirmation type="text/javascript"> function greyText(one_way, return_date) { if (document.form1[one_way].checked) { document.form1[return_date].disabled=true; document.form1[return_flight].disabled=true; } else { document.form1[return_date].disabled=false; document.form1[return_flight].disabled=false; } } Webair Contact Us src="Webair--logo.gif" height= "65" width="240" align="top" /> background="Banner--background.gif" height="60" align="right" width="817" > class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/main_logon.php"> Staff login | class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" > Home | class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" > Booked Flights   class="dropdown" > id="one-ddheader" onmouseover="ddMenu('one',1)" onmouseout="ddMenu('one',-1)" > Home id="one-ddcontent" onmouseover="cancelHide('one')" onmouseout="ddMenu('one',-1)" > href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" class="underline" > Home class="dropdown" > id="two-ddheader" onmouseover="ddMenu('two',1)" onmouseout="ddMenu('two',-1)" > Contact us id="two-ddcontent" onmouseover="cancelHide('two')" onmouseout="ddMenu('two',-1)" > href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact" class="underline" > Contact us class="dropdown" > id="three-ddheader" onmouseover="ddMenu('three',1)" onmouseout="ddMenu('three',-1)" > Flights id="three-ddcontent" onmouseover="cancelHide('three')" onmouseout="ddMenu('three',-1)" > href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_refunds.html" class="underline" > Refund Policy class="dropdown" > id="four-ddheader" onmouseover="ddMenu('four',1)" onmouseout="ddMenu('four',-1)" > Travel Information id="four-ddcontent" onmouseover="cancelHide('four')" onmouseout="ddMenu('four',-1)" > href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_flight_fares.html" class="underline" > Flight Timetable href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_baggage.html" class="underline" > Baggage Information href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_airport_info.html" class="underline" > Airport information href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_travel_info.html" class="underline" > Travel documentation requirements class="dropdown" > id="five-ddheader" onmouseover="ddMenu('five',1)" onmouseout="ddMenu('five',-1)" > About Webair id="five-ddcontent" onmouseover="cancelHide('five')" onmouseout="ddMenu('five',-1)" > href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_about.html" class="underline" > About Webair href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact.html" class="underline" > Contact us style="clear:both" /> id="content" > id="table_gen_1" > class="inner" > //THERE IS AN ERROR display error message if($error) { echo '' . $output . ''; ?> Staff login | Home | Contact us | About Webair } else { ?> Confirm Booking Out-going Flight Information: while($row = mysql_fetch_array($result)){ echo " </pre> <table border="'1'" cellpadding="10"> Flight Number Flight Route Selected Departure Time Arrival Time Departure Date Return Date Number of Passengers Selected ".$row['flight_num']." ".$row['flight_route']." ".$row['departure_time']." ".$row['arrival_time']." ".$date_out." ".$date_return." ".$passenger_num['num_of_pass']." </table> <br><br> <br><br>"; <br>} <br>?><br><br><br><br><div id="footer"> Staff login | Home | Contact us | About Webair </div> <br> <br> <br> <br> <br> }else{<br> <br> echo 'Sorry, couldn\'t find any flights';<br> <br> } <br> <br>mysql_free_result($result); <br>}<br Quote Link to comment https://forums.phpfreaks.com/topic/136553-what-is-wrong-with-my-date-comparison-structure/#findComment-713034 Share on other sites More sharing options...
will_1990 Posted December 11, 2008 Author Share Posted December 11, 2008 Oh ok I see what you mean. You need to have flags that determine if there are errors or not. You should really have an include file for your header and footer. Try this code: <?php $error = FALSE; //database information $host = "stocks"; // Host name $username = "wbennett"; // Mysql username $password = "mysql5"; // Mysql password $db_name = "wbennett"; // Database name $tbl_name1 = "flight_webair"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Variables $flight_route_out = $_POST['flight_route_out']; $flight_route_return = $_POST['flight_route_return']; $date_out = $_POST['departure_date']; $date_return = $_POST['return_date']; $passenger_num = $_POST['num_of_pass']; $one_way = (isset($_POST['one_way'])) ? $_POST['one_way'] : null; // make sure value is available first. if (strtotime($_POST['return_date']) < strtotime($_POST['departure_date'])) { $output = "You cannot book a return flight before your out-going flight!"; $error = TRUE; } else { $output = "You cannot book a return flight before your out-going flight!"; } //To protect MySQL injection $flight_route_out = stripslashes($flight_route_out); $flight_route_return = stripslashes($flight_route_return); $flight_route_out = mysql_real_escape_string($flight_route_out); $flight_route_return = mysql_real_escape_string($flight_route_return); //Queries $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'"; //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'"; //Execute query 1 $result = mysql_query($sql1) or die(mysql_error()); if(mysql_num_rows($result) > 0){ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" href="dropdown2.css" type="text/css" /> <script type="text/javascript" src="dropdown.js"> </script> <script type="text/javascript" src="calendar.js"> </script> <script type="text/javascript" src="enablefield.js"> </script> <title> Booking Confirmation </title> <script type="text/javascript"> function greyText(one_way, return_date) { if (document.form1[one_way].checked) { document.form1[return_date].disabled=true; document.form1[return_flight].disabled=true; } else { document.form1[return_date].disabled=false; document.form1[return_flight].disabled=false; } } <title>Webair Contact Us</title> <link rel="StyleSheet" href="./mainstyle.css"type="text/css" media="screen"> </script> </head> <body> <div id="wrapper"> <table> <tr> <td> <img src="Webair--logo.gif" height= "65" width="240" align="top" /> </td> <td background="Banner--background.gif" height="60" align="right" width="817" > <a class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/main_logon.php"> <b> Staff login </b> </a> | <a class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" > <b> Home </b> </a> | <a class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" > <b> Booked Flights   </b> </a> </td> </tr> </table> <dl class="dropdown" > <dt id="one-ddheader" onmouseover="ddMenu('one',1)" onmouseout="ddMenu('one',-1)" > Home </dt> <dd id="one-ddcontent" onmouseover="cancelHide('one')" onmouseout="ddMenu('one',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" class="underline" > Home </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="two-ddheader" onmouseover="ddMenu('two',1)" onmouseout="ddMenu('two',-1)" > Contact us </dt> <dd id="two-ddcontent" onmouseover="cancelHide('two')" onmouseout="ddMenu('two',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact" class="underline" > Contact us </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="three-ddheader" onmouseover="ddMenu('three',1)" onmouseout="ddMenu('three',-1)" > Flights </dt> <dd id="three-ddcontent" onmouseover="cancelHide('three')" onmouseout="ddMenu('three',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_refunds.html" class="underline" > Refund Policy </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="four-ddheader" onmouseover="ddMenu('four',1)" onmouseout="ddMenu('four',-1)" > Travel Information </dt> <dd id="four-ddcontent" onmouseover="cancelHide('four')" onmouseout="ddMenu('four',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_flight_fares.html" class="underline" > Flight Timetable </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_baggage.html" class="underline" > Baggage Information </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_airport_info.html" class="underline" > Airport information </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_travel_info.html" class="underline" > Travel documentation requirements </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="five-ddheader" onmouseover="ddMenu('five',1)" onmouseout="ddMenu('five',-1)" > About Webair </dt> <dd id="five-ddcontent" onmouseover="cancelHide('five')" onmouseout="ddMenu('five',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_about.html" class="underline" > About Webair </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact.html" class="underline" > Contact us </a> </li> </ul> </dd> </dl> <div style="clear:both" /> </div> <div id="content" > <div id="table_gen_1" > <div class="inner" > <br> <?php //THERE IS AN ERROR display error message if($error) { echo '<h1>' . $output . '</h1>'; ?> <div id="footer"> <div id="inner"> <div id="footer2"> <p><hr class="line"></hr> <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/main_logon.php"><b>Staff login</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html"><b>Home</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact.html"><b>Contact us</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_about.html"><b>About Webair</b></a> <hr class="line2"></hr> </p> </div> </div> </div> <?php } else { ?> <h1><center> Confirm Booking </center></h1> <h3><b><u> Out-going Flight Information: </u></b></h3> <?php while($row = mysql_fetch_array($result)){ echo " <br><br> <table border='1' cellpadding=10> <tr> <td class='table'> <center><b> Flight Number </b></center> </td> <td class='table'> <center><b> Flight Route Selected </b></center> </td> <td class='table'> <center><b> Departure Time </b> </center> </td> <td class='table'> <center><b> Arrival Time </b></center> </td> <td class='table'> <center><b> Departure Date </b></center> </td> <td class='table'> <center><b> Return Date </b></center> </td> <td class='table'> <center><b> Number of Passengers Selected </b></center> </td> </tr> <tr> <td class='table'> <center> ".$row['flight_num']." </center> </td> <td class='table'> <center> ".$row['flight_route']." </center> </td> <td class='table'> <center> ".$row['departure_time']." </center> </td> <td class='table'> <center> ".$row['arrival_time']." </center> </td> <td class='table'> <center> ".$date_out." </center> </td> <td class='table'> <center> ".$date_return." </center> </td> <td class='table'> <center> ".$passenger_num['num_of_pass']." </center> </td> </tr> </table> <br><br>"; } ?> </div> </div> </div> <div id="footer"> <div id="inner"> <div id="footer2"> <p><hr class="line"></hr> <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/main_logon.php"><b>Staff login</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html"><b>Home</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact.html"><b>Contact us</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_about.html"><b>About Webair</b></a> <hr class="line2"></hr> </p> </div> </div> </div> </body> </html> <?php }else{ echo 'Sorry, couldn\'t find any flights'; } mysql_free_result($result); } ?> Nope, i get absoulutely no output to the browser. Quote Link to comment https://forums.phpfreaks.com/topic/136553-what-is-wrong-with-my-date-comparison-structure/#findComment-713049 Share on other sites More sharing options...
Maq Posted December 11, 2008 Share Posted December 11, 2008 Heh, sorry I can't test where I'm at right now. I put error reporting/display on just in-case there is an error somewhere. This should work, I had the '}' in the wrong place: ini_set ("display_errors", "1"); error_reporting(E_ALL); $error = FALSE; //database information $host = "stocks"; // Host name $username = "wbennett"; // Mysql username $password = "mysql5"; // Mysql password $db_name = "wbennett"; // Database name $tbl_name1 = "flight_webair"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Variables $flight_route_out = $_POST['flight_route_out']; $flight_route_return = $_POST['flight_route_return']; $date_out = $_POST['departure_date']; $date_return = $_POST['return_date']; $passenger_num = $_POST['num_of_pass']; $one_way = (isset($_POST['one_way'])) ? $_POST['one_way'] : null; // make sure value is available first. if (strtotime($_POST['return_date']) $output = "You cannot book a return flight before your out-going flight!"; $error = TRUE; } else { $output = "You cannot book a return flight before your out-going flight!"; } //To protect MySQL injection $flight_route_out = stripslashes($flight_route_out); $flight_route_return = stripslashes($flight_route_return); $flight_route_out = mysql_real_escape_string($flight_route_out); $flight_route_return = mysql_real_escape_string($flight_route_return); //Queries $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'"; //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'"; //Execute query 1 $result = mysql_query($sql1) or die(mysql_error()); if(mysql_num_rows($result) > 0){ ?> http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> rel="stylesheet" href="dropdown2.css" type="text/css" /> type="text/javascript" src="dropdown.js"> type="text/javascript" src="calendar.js"> type="text/javascript" src="enablefield.js"> Booking Confirmation type="text/javascript"> function greyText(one_way, return_date) { if (document.form1[one_way].checked) { document.form1[return_date].disabled=true; document.form1[return_flight].disabled=true; } else { document.form1[return_date].disabled=false; document.form1[return_flight].disabled=false; } } Webair Contact Us src="Webair--logo.gif" height= "65" width="240" align="top" /> background="Banner--background.gif" height="60" align="right" width="817" > class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/main_logon.php"> Staff login | class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" > Home | class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" > Booked Flights   class="dropdown" > id="one-ddheader" onmouseover="ddMenu('one',1)" onmouseout="ddMenu('one',-1)" > Home id="one-ddcontent" onmouseover="cancelHide('one')" onmouseout="ddMenu('one',-1)" > href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" class="underline" > Home class="dropdown" > id="two-ddheader" onmouseover="ddMenu('two',1)" onmouseout="ddMenu('two',-1)" > Contact us id="two-ddcontent" onmouseover="cancelHide('two')" onmouseout="ddMenu('two',-1)" > href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact" class="underline" > Contact us class="dropdown" > id="three-ddheader" onmouseover="ddMenu('three',1)" onmouseout="ddMenu('three',-1)" > Flights id="three-ddcontent" onmouseover="cancelHide('three')" onmouseout="ddMenu('three',-1)" > href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_refunds.html" class="underline" > Refund Policy class="dropdown" > id="four-ddheader" onmouseover="ddMenu('four',1)" onmouseout="ddMenu('four',-1)" > Travel Information id="four-ddcontent" onmouseover="cancelHide('four')" onmouseout="ddMenu('four',-1)" > href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_flight_fares.html" class="underline" > Flight Timetable href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_baggage.html" class="underline" > Baggage Information href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_airport_info.html" class="underline" > Airport information href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_travel_info.html" class="underline" > Travel documentation requirements class="dropdown" > id="five-ddheader" onmouseover="ddMenu('five',1)" onmouseout="ddMenu('five',-1)" > About Webair id="five-ddcontent" onmouseover="cancelHide('five')" onmouseout="ddMenu('five',-1)" > href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_about.html" class="underline" > About Webair href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact.html" class="underline" > Contact us style="clear:both" /> id="content" > id="table_gen_1" > class="inner" > //THERE IS AN ERROR display error message if($error) { echo '' . $output . ''; ?> Staff login | Home | Contact us | About Webair } else { ?> Confirm Booking Out-going Flight Information: while($row = mysql_fetch_array($result)){ echo " </pre> <table border="'1'" cellpadding="10"> Flight Number Flight Route Selected Departure Time Arrival Time Departure Date Return Date Number of Passengers Selected ".$row['flight_num']." ".$row['flight_route']." ".$row['departure_time']." ".$row['arrival_time']." ".$date_out." ".$date_return." ".$passenger_num['num_of_pass']." </table> <br><br> <br><br>"; <br>} <br>?><br><br><br><br><br><div id="footer"> Staff login | Home | Contact us | About Webair </div> <br><br> <br> <br> <br> <br> }else{<br> <br> echo 'Sorry, couldn\'t find any flights';<br> <br> } <br> <br>mysql_free_result($result); <br Quote Link to comment https://forums.phpfreaks.com/topic/136553-what-is-wrong-with-my-date-comparison-structure/#findComment-713053 Share on other sites More sharing options...
will_1990 Posted December 11, 2008 Author Share Posted December 11, 2008 Heh, sorry I can't test where I'm at right now. I put error reporting/display on just in-case there is an error somewhere. This should work, I had the '}' in the wrong place: <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); $error = FALSE; //database information $host = "stocks"; // Host name $username = "wbennett"; // Mysql username $password = "mysql5"; // Mysql password $db_name = "wbennett"; // Database name $tbl_name1 = "flight_webair"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Variables $flight_route_out = $_POST['flight_route_out']; $flight_route_return = $_POST['flight_route_return']; $date_out = $_POST['departure_date']; $date_return = $_POST['return_date']; $passenger_num = $_POST['num_of_pass']; $one_way = (isset($_POST['one_way'])) ? $_POST['one_way'] : null; // make sure value is available first. if (strtotime($_POST['return_date']) < strtotime($_POST['departure_date'])) { $output = "You cannot book a return flight before your out-going flight!"; $error = TRUE; } else { $output = "You cannot book a return flight before your out-going flight!"; } //To protect MySQL injection $flight_route_out = stripslashes($flight_route_out); $flight_route_return = stripslashes($flight_route_return); $flight_route_out = mysql_real_escape_string($flight_route_out); $flight_route_return = mysql_real_escape_string($flight_route_return); //Queries $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'"; //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'"; //Execute query 1 $result = mysql_query($sql1) or die(mysql_error()); if(mysql_num_rows($result) > 0){ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" href="dropdown2.css" type="text/css" /> <script type="text/javascript" src="dropdown.js"> </script> <script type="text/javascript" src="calendar.js"> </script> <script type="text/javascript" src="enablefield.js"> </script> <title> Booking Confirmation </title> <script type="text/javascript"> function greyText(one_way, return_date) { if (document.form1[one_way].checked) { document.form1[return_date].disabled=true; document.form1[return_flight].disabled=true; } else { document.form1[return_date].disabled=false; document.form1[return_flight].disabled=false; } } <title>Webair Contact Us</title> <link rel="StyleSheet" href="./mainstyle.css"type="text/css" media="screen"> </script> </head> <body> <div id="wrapper"> <table> <tr> <td> <img src="Webair--logo.gif" height= "65" width="240" align="top" /> </td> <td background="Banner--background.gif" height="60" align="right" width="817" > <a class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/main_logon.php"> <b> Staff login </b> </a> | <a class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" > <b> Home </b> </a> | <a class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" > <b> Booked Flights   </b> </a> </td> </tr> </table> <dl class="dropdown" > <dt id="one-ddheader" onmouseover="ddMenu('one',1)" onmouseout="ddMenu('one',-1)" > Home </dt> <dd id="one-ddcontent" onmouseover="cancelHide('one')" onmouseout="ddMenu('one',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" class="underline" > Home </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="two-ddheader" onmouseover="ddMenu('two',1)" onmouseout="ddMenu('two',-1)" > Contact us </dt> <dd id="two-ddcontent" onmouseover="cancelHide('two')" onmouseout="ddMenu('two',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact" class="underline" > Contact us </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="three-ddheader" onmouseover="ddMenu('three',1)" onmouseout="ddMenu('three',-1)" > Flights </dt> <dd id="three-ddcontent" onmouseover="cancelHide('three')" onmouseout="ddMenu('three',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_refunds.html" class="underline" > Refund Policy </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="four-ddheader" onmouseover="ddMenu('four',1)" onmouseout="ddMenu('four',-1)" > Travel Information </dt> <dd id="four-ddcontent" onmouseover="cancelHide('four')" onmouseout="ddMenu('four',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_flight_fares.html" class="underline" > Flight Timetable </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_baggage.html" class="underline" > Baggage Information </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_airport_info.html" class="underline" > Airport information </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_travel_info.html" class="underline" > Travel documentation requirements </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="five-ddheader" onmouseover="ddMenu('five',1)" onmouseout="ddMenu('five',-1)" > About Webair </dt> <dd id="five-ddcontent" onmouseover="cancelHide('five')" onmouseout="ddMenu('five',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_about.html" class="underline" > About Webair </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact.html" class="underline" > Contact us </a> </li> </ul> </dd> </dl> <div style="clear:both" /> </div> <div id="content" > <div id="table_gen_1" > <div class="inner" > <br> <?php //THERE IS AN ERROR display error message if($error) { echo '<h1>' . $output . '</h1>'; ?> <div id="footer"> <div id="inner"> <div id="footer2"> <p><hr class="line"></hr> <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/main_logon.php"><b>Staff login</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html"><b>Home</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact.html"><b>Contact us</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_about.html"><b>About Webair</b></a> <hr class="line2"></hr> </p> </div> </div> </div> <?php } else { ?> <h1><center> Confirm Booking </center></h1> <h3><b><u> Out-going Flight Information: </u></b></h3> <?php while($row = mysql_fetch_array($result)){ echo " <br><br> <table border='1' cellpadding=10> <tr> <td class='table'> <center><b> Flight Number </b></center> </td> <td class='table'> <center><b> Flight Route Selected </b></center> </td> <td class='table'> <center><b> Departure Time </b> </center> </td> <td class='table'> <center><b> Arrival Time </b></center> </td> <td class='table'> <center><b> Departure Date </b></center> </td> <td class='table'> <center><b> Return Date </b></center> </td> <td class='table'> <center><b> Number of Passengers Selected </b></center> </td> </tr> <tr> <td class='table'> <center> ".$row['flight_num']." </center> </td> <td class='table'> <center> ".$row['flight_route']." </center> </td> <td class='table'> <center> ".$row['departure_time']." </center> </td> <td class='table'> <center> ".$row['arrival_time']." </center> </td> <td class='table'> <center> ".$date_out." </center> </td> <td class='table'> <center> ".$date_return." </center> </td> <td class='table'> <center> ".$passenger_num['num_of_pass']." </center> </td> </tr> </table> <br><br>"; } ?> </div> </div> </div> <div id="footer"> <div id="inner"> <div id="footer2"> <p><hr class="line"></hr> <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/main_logon.php"><b>Staff login</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html"><b>Home</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact.html"><b>Contact us</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_about.html"><b>About Webair</b></a> <hr class="line2"></hr> </p> </div> </div> </div> <?php } ?> </body> </html> <?php }else{ echo 'Sorry, couldn\'t find any flights'; } mysql_free_result($result); ?> This returns the while loop etc but does not execute any die statment or anything if you use a return date < date_out... thanks so much for all your help at the moment i really apprciate it Quote Link to comment https://forums.phpfreaks.com/topic/136553-what-is-wrong-with-my-date-comparison-structure/#findComment-713062 Share on other sites More sharing options...
Maq Posted December 11, 2008 Share Posted December 11, 2008 One more time! ini_set ("display_errors", "1"); error_reporting(E_ALL); $error = FALSE; //database information $host = "stocks"; // Host name $username = "wbennett"; // Mysql username $password = "mysql5"; // Mysql password $db_name = "wbennett"; // Database name $tbl_name1 = "flight_webair"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Variables $flight_route_out = $_POST['flight_route_out']; $flight_route_return = $_POST['flight_route_return']; $date_out = $_POST['departure_date']; $date_return = $_POST['return_date']; $passenger_num = $_POST['num_of_pass']; $one_way = (isset($_POST['one_way'])) ? $_POST['one_way'] : null; // make sure value is available first. if (strtotime($_POST['return_date']) $output = "You cannot book a return flight before your out-going flight!"; $error = TRUE; } //To protect MySQL injection $flight_route_out = stripslashes($flight_route_out); $flight_route_return = stripslashes($flight_route_return); $flight_route_out = mysql_real_escape_string($flight_route_out); $flight_route_return = mysql_real_escape_string($flight_route_return); //Queries $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'"; //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'"; //Execute query 1 $result = mysql_query($sql1) or die(mysql_error()); if(mysql_num_rows($result) > 0){ ?> http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> rel="stylesheet" href="dropdown2.css" type="text/css" /> type="text/javascript" src="dropdown.js"> type="text/javascript" src="calendar.js"> type="text/javascript" src="enablefield.js"> Booking Confirmation type="text/javascript"> function greyText(one_way, return_date) { if (document.form1[one_way].checked) { document.form1[return_date].disabled=true; document.form1[return_flight].disabled=true; } else { document.form1[return_date].disabled=false; document.form1[return_flight].disabled=false; } } Webair Contact Us src="Webair--logo.gif" height= "65" width="240" align="top" /> background="Banner--background.gif" height="60" align="right" width="817" > class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/main_logon.php"> Staff login | class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" > Home | class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" > Booked Flights   class="dropdown" > id="one-ddheader" onmouseover="ddMenu('one',1)" onmouseout="ddMenu('one',-1)" > Home id="one-ddcontent" onmouseover="cancelHide('one')" onmouseout="ddMenu('one',-1)" > href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" class="underline" > Home class="dropdown" > id="two-ddheader" onmouseover="ddMenu('two',1)" onmouseout="ddMenu('two',-1)" > Contact us id="two-ddcontent" onmouseover="cancelHide('two')" onmouseout="ddMenu('two',-1)" > href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact" class="underline" > Contact us class="dropdown" > id="three-ddheader" onmouseover="ddMenu('three',1)" onmouseout="ddMenu('three',-1)" > Flights id="three-ddcontent" onmouseover="cancelHide('three')" onmouseout="ddMenu('three',-1)" > href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_refunds.html" class="underline" > Refund Policy class="dropdown" > id="four-ddheader" onmouseover="ddMenu('four',1)" onmouseout="ddMenu('four',-1)" > Travel Information id="four-ddcontent" onmouseover="cancelHide('four')" onmouseout="ddMenu('four',-1)" > href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_flight_fares.html" class="underline" > Flight Timetable href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_baggage.html" class="underline" > Baggage Information href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_airport_info.html" class="underline" > Airport information href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_travel_info.html" class="underline" > Travel documentation requirements class="dropdown" > id="five-ddheader" onmouseover="ddMenu('five',1)" onmouseout="ddMenu('five',-1)" > About Webair id="five-ddcontent" onmouseover="cancelHide('five')" onmouseout="ddMenu('five',-1)" > href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_about.html" class="underline" > About Webair href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact.html" class="underline" > Contact us style="clear:both" /> id="content" > id="table_gen_1" > class="inner" > //THERE IS AN ERROR display error message if($error == TRUE) { echo '' . $output . ''; ?> Staff login | Home | Contact us | About Webair } else { ?> Confirm Booking Out-going Flight Information: while($row = mysql_fetch_array($result)){ echo " </pre> <table border="'1'" cellpadding="10"> Flight Number Flight Route Selected Departure Time Arrival Time Departure Date Return Date Number of Passengers Selected ".$row['flight_num']." ".$row['flight_route']." ".$row['departure_time']." ".$row['arrival_time']." ".$date_out." ".$date_return." ".$passenger_num['num_of_pass']." </table> <br><br> <br><br>"; <br>} <br>?><br><br><br><br><br><div id="footer"> Staff login | Home | Contact us | About Webair </div> <br><br> <br> <br> <br> <br> }else{<br> <br> echo 'Sorry, couldn\'t find any flights';<br> <br> } <br> <br>mysql_free_result($result); <br Quote Link to comment https://forums.phpfreaks.com/topic/136553-what-is-wrong-with-my-date-comparison-structure/#findComment-713074 Share on other sites More sharing options...
will_1990 Posted December 11, 2008 Author Share Posted December 11, 2008 One more time! <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); $error = FALSE; //database information $host = "stocks"; // Host name $username = "wbennett"; // Mysql username $password = "mysql5"; // Mysql password $db_name = "wbennett"; // Database name $tbl_name1 = "flight_webair"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Variables $flight_route_out = $_POST['flight_route_out']; $flight_route_return = $_POST['flight_route_return']; $date_out = $_POST['departure_date']; $date_return = $_POST['return_date']; $passenger_num = $_POST['num_of_pass']; $one_way = (isset($_POST['one_way'])) ? $_POST['one_way'] : null; // make sure value is available first. if (strtotime($_POST['return_date']) < strtotime($_POST['departure_date'])) { $output = "You cannot book a return flight before your out-going flight!"; $error = TRUE; } //To protect MySQL injection $flight_route_out = stripslashes($flight_route_out); $flight_route_return = stripslashes($flight_route_return); $flight_route_out = mysql_real_escape_string($flight_route_out); $flight_route_return = mysql_real_escape_string($flight_route_return); //Queries $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'"; //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'"; //Execute query 1 $result = mysql_query($sql1) or die(mysql_error()); if(mysql_num_rows($result) > 0){ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" href="dropdown2.css" type="text/css" /> <script type="text/javascript" src="dropdown.js"> </script> <script type="text/javascript" src="calendar.js"> </script> <script type="text/javascript" src="enablefield.js"> </script> <title> Booking Confirmation </title> <script type="text/javascript"> function greyText(one_way, return_date) { if (document.form1[one_way].checked) { document.form1[return_date].disabled=true; document.form1[return_flight].disabled=true; } else { document.form1[return_date].disabled=false; document.form1[return_flight].disabled=false; } } <title>Webair Contact Us</title> <link rel="StyleSheet" href="./mainstyle.css"type="text/css" media="screen"> </script> </head> <body> <div id="wrapper"> <table> <tr> <td> <img src="Webair--logo.gif" height= "65" width="240" align="top" /> </td> <td background="Banner--background.gif" height="60" align="right" width="817" > <a class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/main_logon.php"> <b> Staff login </b> </a> | <a class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" > <b> Home </b> </a> | <a class="hyperlink" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" > <b> Booked Flights   </b> </a> </td> </tr> </table> <dl class="dropdown" > <dt id="one-ddheader" onmouseover="ddMenu('one',1)" onmouseout="ddMenu('one',-1)" > Home </dt> <dd id="one-ddcontent" onmouseover="cancelHide('one')" onmouseout="ddMenu('one',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html" class="underline" > Home </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="two-ddheader" onmouseover="ddMenu('two',1)" onmouseout="ddMenu('two',-1)" > Contact us </dt> <dd id="two-ddcontent" onmouseover="cancelHide('two')" onmouseout="ddMenu('two',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact" class="underline" > Contact us </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="three-ddheader" onmouseover="ddMenu('three',1)" onmouseout="ddMenu('three',-1)" > Flights </dt> <dd id="three-ddcontent" onmouseover="cancelHide('three')" onmouseout="ddMenu('three',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_refunds.html" class="underline" > Refund Policy </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="four-ddheader" onmouseover="ddMenu('four',1)" onmouseout="ddMenu('four',-1)" > Travel Information </dt> <dd id="four-ddcontent" onmouseover="cancelHide('four')" onmouseout="ddMenu('four',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_flight_fares.html" class="underline" > Flight Timetable </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_baggage.html" class="underline" > Baggage Information </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_airport_info.html" class="underline" > Airport information </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_travel_info.html" class="underline" > Travel documentation requirements </a> </li> </ul> </dd> </dl> <dl class="dropdown" > <dt id="five-ddheader" onmouseover="ddMenu('five',1)" onmouseout="ddMenu('five',-1)" > About Webair </dt> <dd id="five-ddcontent" onmouseover="cancelHide('five')" onmouseout="ddMenu('five',-1)" > <ul> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_about.html" class="underline" > About Webair </a> </li> <li> <a href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact.html" class="underline" > Contact us </a> </li> </ul> </dd> </dl> <div style="clear:both" /> </div> <div id="content" > <div id="table_gen_1" > <div class="inner" > <br> <?php //THERE IS AN ERROR display error message if($error == TRUE) { echo '<h1>' . $output . '</h1>'; ?> <div id="footer"> <div id="inner"> <div id="footer2"> <p><hr class="line"></hr> <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/main_logon.php"><b>Staff login</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html"><b>Home</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact.html"><b>Contact us</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_about.html"><b>About Webair</b></a> <hr class="line2"></hr> </p> </div> </div> </div> <?php } else { ?> <h1><center> Confirm Booking </center></h1> <h3><b><u> Out-going Flight Information: </u></b></h3> <?php while($row = mysql_fetch_array($result)){ echo " <br><br> <table border='1' cellpadding=10> <tr> <td class='table'> <center><b> Flight Number </b></center> </td> <td class='table'> <center><b> Flight Route Selected </b></center> </td> <td class='table'> <center><b> Departure Time </b> </center> </td> <td class='table'> <center><b> Arrival Time </b></center> </td> <td class='table'> <center><b> Departure Date </b></center> </td> <td class='table'> <center><b> Return Date </b></center> </td> <td class='table'> <center><b> Number of Passengers Selected </b></center> </td> </tr> <tr> <td class='table'> <center> ".$row['flight_num']." </center> </td> <td class='table'> <center> ".$row['flight_route']." </center> </td> <td class='table'> <center> ".$row['departure_time']." </center> </td> <td class='table'> <center> ".$row['arrival_time']." </center> </td> <td class='table'> <center> ".$date_out." </center> </td> <td class='table'> <center> ".$date_return." </center> </td> <td class='table'> <center> ".$passenger_num['num_of_pass']." </center> </td> </tr> </table> <br><br>"; } ?> </div> </div> </div> <div id="footer"> <div id="inner"> <div id="footer2"> <p><hr class="line"></hr> <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/main_logon.php"><b>Staff login</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/index.html"><b>Home</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_contact.html"><b>Contact us</b></a> | <a class="hyperlink2" href="http://www.cems.uwe.ac.uk/~wbennett/webair/webair_about.html"><b>About Webair</b></a> <hr class="line2"></hr> </p> </div> </div> </div> <?php } ?> </body> </html> <?php }else{ echo 'Sorry, couldn\'t find any flights'; } mysql_free_result($result); ?> nope no changes............. What is left to try, can you see why it isnt doing this, i think its because its a while script possible set this to an else script related to the terms of date being all ok? what do you think? Quote Link to comment https://forums.phpfreaks.com/topic/136553-what-is-wrong-with-my-date-comparison-structure/#findComment-713080 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.