coalduststar Posted March 13, 2006 Share Posted March 13, 2006 I have this form to do a booking for a taxi, to or from an airport. I have a similar form elsewhere in the site with more or less identical update code (i used server behaviours in dreamweaver then modified the code) and that one works correctly.If i leave in the validation funtion it acts as if there have been no values put into the form and if i remove it, the browser says this :You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ':10:00, 'Belfast International Airport', 'eaz345', 'executive',I tried debugging the SQL but i probably got that wrong as there was no result when i tried to get the $insertSQL to print- i would appreciate any and all advice!Thanks[code]<?php require_once('../Connections/connEcabs.php'); ?><?phpsession_start();$MM_authorizedUsers = "";$MM_donotCheckaccess = "true";// *** Restrict Access To Page: Grant or deny access to this pagefunction isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && true) { $isValid = true; } } return $isValid; }$MM_restrictGoTo = "corp_login.php";if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) $MM_referrer .= "?" . $QUERY_STRING; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit;}?><?phpinclude "corpairvalidate.php";function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue;}$editFormAction = $_SERVER['PHP_SELF'];if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);}if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "book") && $_REQUEST['direction'] == "to" && php_validate()) { $insertSQL = sprintf("INSERT INTO corporate (corp_name, corp_phone, corp_email, corp_pickup_house_no, corp_pickup_add1, corp_pickup_add2, corp_pickup_post_code, corp_dest_add1, corp_people, corp_date, corp_time, corp_airport, corp_flight_no, corp_car_type, corp_wheelchair, corp_info, corp_journey_type, corp_auth) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['corp_name'], "text"), GetSQLValueString($_POST['corp_phone'], "text"), GetSQLValueString($_POST['corp_email'], "text"), GetSQLValueString($_POST['corp_pickup_house_no'], "int"), GetSQLValueString($_POST['corp_pickup_add1'], "text"), GetSQLValueString($_POST['corp_pickup_add2'], "text"), GetSQLValueString($_POST['corp_pickup_post_code'], "text"), GetSQLValueString($_POST['corp_airport'], "text"), GetSQLValueString($_POST['corp_people'], "int"), GetSQLValueString($_POST['year'] . "-" . $_POST['month'] . "-" . $_POST['day'], "date"), GetSQLValueString($_POST['hours'] . ":" . $_POST['mins'] . ":00", "time"), GetSQLValueString($_POST['corp_airport'], "text"), GetSQLValueString($_POST['corp_flight_no'], "text"), GetSQLValueString($_POST['corp_car_type'], "text"), GetSQLValueString(isset($_POST['corp_wheelchair']) ? "true" : "", "defined","1","0"), GetSQLValueString($_POST['corp_info'], "text"), GetSQLValueString($_POST['corp_journey_type'], "text"), GetSQLValueString($_POST['corp_auth'], "text")); exit; mysql_select_db($database_connEcabs, $connEcabs); $Result1 = mysql_query($insertSQL, $connEcabs) or die(mysql_error()); $insertGoTo = "thanks.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo));}else{if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "book") && $_REQUEST['direction'] == "from" && php_validate()) { $insertSQL = sprintf("INSERT INTO corporate (corp_name, corp_phone, corp_email, corp_pickup_add1, corp_dest_house_no, corp_dest_add1, corp_dest_add2, corp_dest_post_code, corp_people, corp_date, corp_time, corp_airport, corp_flight_no, corp_car_type, corp_wheelchair, corp_info, corp_journey_type, corp_auth) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['corp_name'], "text"), GetSQLValueString($_POST['corp_phone'], "text"), GetSQLValueString($_POST['corp_email'], "text"), GetSQLValueString($_POST['corp_airport'], "text"), GetSQLValueString($_POST['corp_dest_house_no'], "int"), GetSQLValueString($_POST['corp_dest_add1'], "text"), GetSQLValueString($_POST['corp_dest_add2'], "text"), GetSQLValueString($_POST['corp_dest_post_code'], "text"), GetSQLValueString($_POST['corp_people'], "int"), GetSQLValueString($_POST['year'] . "-" . $_POST['month'] . "-" . $_POST['day'], "date"), GetSQLValueString($_POST['hours'] . ":" . $_POST['mins'] . ":00", "time"), GetSQLValueString($_POST['corp_airport'], "text"), GetSQLValueString($_POST['corp_flight_no'], "text"), GetSQLValueString($_POST['corp_car_type'], "text"), GetSQLValueString(isset($_POST['corp_wheelchair']) ? "true" : "", "defined","1","0"), GetSQLValueString($_POST['corp_info'], "text"), GetSQLValueString($_POST['corp_journey_type'], "text"), GetSQLValueString($_POST['corp_auth'], "text")); mysql_select_db($database_connEcabs, $connEcabs); $Result1 = mysql_query($insertSQL, $connEcabs) or die(mysql_error()); $insertGoTo = "thanks.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo));}}$colname_corp_details = "1";if (isset($_POST['login_name'])) { $colname_corp_details = (get_magic_quotes_gpc()) ? $_POST['login_name'] : addslashes($_POST['login_name']);}mysql_select_db($database_connEcabs, $connEcabs);$query_corp_details = sprintf("SELECT * FROM login WHERE login_name = '$MM_Username'", $colname_corp_details);$corp_details = mysql_query($query_corp_details, $connEcabs) or die(mysql_error());$row_corp_details = mysql_fetch_assoc($corp_details);$totalRows_corp_details = mysql_num_rows($corp_details);?><html><head><title>Book an e-CAB Online!</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="description" content="e-CABs Northern Ireland taxi company with online booking facility and corporate account facilities."><meta name="keywords" content="taxi, airport, travel, e-CAB, eddie, tucker, northern, ireland, cab"><link rel="stylesheet" type="text/css" href="ecabs.css" /><!-- <script language='javascript' type='text/javascript' src='validate.js'></script>--><script language="JavaScript" type="text/JavaScript"><!--function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;}function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}}function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x;}function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}}//--></script></head><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('images/slice9-about_09.gif','images/slice10-service_10.gif','images/slice12-book_12.gif','images/slice14-contact_14.gif','images/almost2_13.gif','images/almost2_14.gif','images/almost2_16.gif','images/almost2_15.gif')"><!-- Header table begin --><table id="header" width="821" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <img src="images/index_01.gif" width="820" height="50" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="50" alt=""></td> </tr> <tr> <td> <img src="images/index_02.gif" width="820" height="135" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="135" alt=""></td> </tr> <tr> <td> <img src="images/index_03.gif" width="820" height="48" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="48" alt=""></td> </tr> <tr> <td> <img src="images/index_04.gif" width="820" height="36" alt=""></td> </tr></table> <!-- End of header table --> <table id="middle" width="821" border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="top"> <!-- Navigation table begin --> <table id="navigation" width="280" border="0" cellpadding="0" cellspacing="0"> <tr> <td colspan="2" align="right"> <img src="images/index_06.gif" width="169" height="30" alt=""></td> </tr> <tr> <td><a href="index.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('about','','images/slice9-about_09.gif',1)"><img src="images/index_09.gif" alt="e-cabs home page" name="about" width="280" height="28" border="0"></a></td> </tr> <tr> <td><a href="service.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('service','','images/slice10-service_10.gif',1)"><img src="images/index_10.gif" alt="a description of our services" name="service" width="280" height="29" border="0"></a></td> </tr> <tr> <td><a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('book','','images/slice12-book_12.gif',1)"><img src="images/index_12.gif" alt="book a taxi online!" name="book" width="280" height="29" border="0"></a></td> </tr> <tr> <td><a href="contact.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('contact','','images/slice14-contact_14.gif',1)"><img src="images/index_14.gif" alt="contact us" name="contact" width="280" height="29" border="0"></a></td> </tr> <tr> <td colspan="2" class="navback"></td> </tr> <tr> <td colspan="2" align="right"> <img src="images/index_17.gif" width="169" height="30" alt=""></td> </tr></table> </td> <!-- End navigation --> <!-- content table begin --> <td valign="top"> <table id="content" width="541" border="0" cellpadding="0" cellspacing="0"> <tr> <td><img src="images/slice7-booktitle_07.gif" width="495" height="58"></td> </tr> <tr> <td class="contentback"> <p><table border="0" cellpadding="0" cellspacing="0" align="center"> <tr> <td align="left"> <img src="images/bookingbtns_12.gif" width="42" height="75"> </td> <td align="left"> <a href="book.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('one way','','images/almost2_15.gif',1)"><img src="images/bookingbtns_15.gif" alt="Book a one way journey!" name="one way" width="61" height="75" border="0"></a> </td> <td align="left"> <a href="bookreturn.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('return','','images/almost2_14.gif',1)"><img src="images/bookingbtns_14.gif" alt="Book a return journey!" name="return" width="51" height="75" border="0"></a> </td> <td align="left"> <a href="bookairport.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('airport','','images/almost2_13.gif',1)"><img src="images/bookingbtns_13.gif" alt="Book an airport run!" name="airport" width="63" height="75" border="0"></a> </td> <td align="left"> <a href="bookcorp.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('corp','','images/almost2_16.gif',1)"><img src="images/bookingbtns_16.gif" alt="Book a corporate journey!" name="corp" width="65" height="75" border="0"></a> </td> <td align="left"> <img src="images/bookingbtns_17.gif" width="51" height="75"> </td> </tr></table> </p> <p>Fill out the form below to book a taxi online. Please ensure all the required fields are filled out.</p> <p>Please note that bookings MUST be made 24 hours in advance and are only confirmed once you have received an email confirming the details. </p> <form name="book" action="<?php echo $editFormAction; ?>" method="POST" class="form" onSubmit="return jsvalidate(this)"> <table width="350" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="2"><h3>Journey Type</h3></td> </tr> <tr> <td colspan="2" align="center"><select name="corp_journey_type"> <option value="one way" onclick="document.location='bookcorp.php';">one way</option> <option value="return" onclick="document.location='bookcorpreturn.php';">return</option> <option selected value="airport" onclick="document.location='bookcorpairport.php';">airport</option> </select> </td> </tr> <tr> <td colspan="2"><h3>Customer Details</h3></td> </tr> <tr> <td width="133" align="right">Acc No.</td> <td width="217" align="left" class="form"><input name="acc_no" type="text" value="<?php echo $row_corp_details['acc_no']; ?>" size="20" disabled></td> </tr> <tr> <td align="right">Name</td> <td align="left" class="form"><input name="corp_name" type="text" value="<?php echo $row_corp_details['login_name']; ?>" size="20"></td> </tr> <tr> <td align="right">Telephone</td> <td align="left" class="form"><input name="corp_phone" type="text" id="homphon" value="<?php echo $row_corp_details['login_tel']; ?>" size="20"></td> </tr> <tr> <td align="right">Email Address</td> <td align="left" class="form"><input name="corp_email" type="text" id="email" size="20"></td> </tr> <tr> <td colspan="2"><h3>Aiport</h3></td> </tr> <tr> <td align="right" class="form">To Airport <input name="direction" type="radio" value="to" checked></td> <td align="left" class="form"><input name="direction" type="radio" value="from">From Airport</td> </tr> <tr> <td align="right">Airport</td> <td align="left" class="form"><select name="corp_airport" id="airportarrive"> <option value="Belfast International Airport" selected>Belfast International Airport</option> <option value="Belfast City Airport">Belfast City Airport</option> <option value="City of Derry Airport">City of Derry Airport</option> <option value="Saint Angelo (Enniskillen) Airport">Saint Angelo (Enniskillen) Airport</option> </select> </tr> <tr> <td align="right">Flight No.</td> <td align="left" class="form"><input name="corp_flight_no" id="flight_no" type="text" maxlength="10" size="10"></td> </tr> <tr> <td colspan="2"><h3>Journey: Pickup/Destination </h3></td> </tr> <tr> <td align="right">House No.</td> <td align="left" class="form"><input name="corp_pickup_house_no" id="corp_pickup_house_no" type="text" maxlength="5" size="5"></td> </tr> <tr> <td align="right">Street</td> <td align="left" class="form"><input name="corp_pickup_add1" id="corp_pickup_add1" type="text" maxlength="30" size="20"></td> </tr> <tr> <td align="right">City/Town</td> <td align="left" class="form"><input name="corp_pickup_add2" id="corp_pickup_add2" type="text" maxlength="30" size="20"></td> </tr> <tr> <td align="right">Postal Code</td> <td align="left" class="form"><input name="corp_pickup_post_code" id="corp_pickup_post_code" type="text" maxlength="7" size="7"></td> </tr> <tr> <td colspan="2"><h3>Times and Details</h3></td> </tr> <tr> <td align="right">Car Type</td> <td align="left" class="form"><select name="corp_car_type" id="corp_car_type"> <option selected value="standard">standard</option> <option value="executive">executive</option> </select> </td> </tr> <tr> <td align="right">Number of Passengers</td> <td align="left" class="form"> <select name="corp_people" id="corp_people"> <option value="01" selected>1</option> <option value="02">2</option> <option value="03">3</option> <option value="04">4</option> <option value="05">5</option> <option value="06">6</option> <option value="07">7</option> <option value="08">8</option> <option value="09">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12+</option> </select> </td> </tr> <tr> <td align="right">Date Required</td> <td align="left" class="form"> <select name="day"> <option value="01" selected>1</option> <option value="02">2</option> <option value="03">3</option> <option value="04">4</option> <option value="05">5</option> <option value="06">6</option> <option value="07">7</option> <option value="08">8</option> <option value="09">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="18">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <select name="month"> <option value="01" selected>January</option> <option value="02">February</option> <option value="03">March</option> <option value="04">April</option> <option value="05">May</option> <option value="06">June</option> <option value="07">July</option> <option value="08">August</option> <option value="09">September</option> <option value="10">October</option> <option value="11">November</option> <option value="12">December</option> </select> <select name="year"> <option value="2005" selected>2005</option> <option value="2006">2006</option> <option value="2007">2007</option> <option value="2008">2008</option> <option value="2009">2009</option> <option value="2010">2010</option> <option value="2011">2011</option> <option value="2012">2012</option> <option value="2013">2013</option> <option value="2014">2014</option> <option value="2015">2015</option> <option value="2016">2016</option> <option value="2017">2017</option> <option value="2018">2018</option> <option value="2019">2019</option> <option value="2020">2020</option> </select> </td> </tr> <tr> <td align="right">Required Time</td> <td align="left" class="form"><select name="hours"> <option value="00">0</option> <option value="01">1</option> <option value="02">2</option> <option value="03">3</option> <option value="04">4</option> <option value="05">5</option> <option value="06">6</option> <option value="07">7</option> <option value="08">8</option> <option value="09">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13" selected>13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> </select> : <select name="mins"> <option value="00" selected>00</option> <option value="05">05</option> <option value="10">10</option> <option value="15">15</option> <option value="20">20</option> <option value="25">25</option> <option value="30">30</option> <option value="35">35</option> <option value="40">40</option> <option value="45">45</option> <option value="50">50</option> <option value="55">55</option> </select> </td> </tr> <tr> <td align="right">Wheelchair Access</td> <td align="left" class="form"><input name="corp_wheelchair" type="checkbox" value="wheelchair access"> </td> </tr> <tr> <td align="right">Extra Information</td> <td align="left" class="form"><textarea name="corp_info" id="corp_info"></textarea></td> </tr> <tr> <td align="right">Authorised by</td> <td align="left" class="form"><input name="corp_auth" id="corp_auth" type="text" maxlength="30" size="20"></td> </tr> <tr> <td align="right"><a href="terms.html" target="_blank">Terms and Conditions</a></td> <td align="left" class="form"><input name="corp_terms" type="checkbox" value="terms"></td> </tr> <tr> <td align="center" colspan="2"><input type="submit" value="book now!"></td> </tr></table> <input type="hidden" name="MM_insert" value="book"> </form> </td> </tr> <tr> <td> <img src="images/index_19.gif" width="495" height="25" alt=""></td> </tr> </table> <!-- End content --> </td> </tr></table> <!-- footer table begin --> <table id="footer" width="821" border="0" cellpadding="0" cellspacing="0"> <tr> <td colspan="4"> <img src="images/index_20.gif" width="820" height="226" alt=""></td> </tr></table><!-- End footer --></body></html><?phpmysql_free_result($corp_details);?>[/code] Link to comment https://forums.phpfreaks.com/topic/4843-more-form-trouble/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.