maxudaskin Posted January 9, 2008 Share Posted January 9, 2008 <?php if(!logged_in){ echo 'You cannot access this page as you are not logged in.'; }else{ $pid = $_SESSION['username']; $bidcheckprevsql = mysql_query("SELECT * FROM flightbids WHERE pid = '{$pid}'"); $bidcheck = mysql_num_rows($bidcheckprevsql); if($bidcheck!=0){ echo 'You cannot bid another flight as you have one already bid. Please file it or delete it.'; $bidcheck = ''; $bidcheckprevsql = ''; }else{ echo $bidcheck; $bidcheck = ''; $bidcheckprevsql = ''; echo $bidcheck; if(isset($_POST['bid_flight'])){ $pid = $_SESSION['username']; $dept = $_POST['dept']; $dest = $_POST['dest']; $fltnum = $_POST['fltnum']; $aircraft = $_POST['aircraft']; $username = $_SESSION['username']; $rank = $_SESSION['rank']; $name = $_SESSION['name']; $route = $_POST['route']; $tail = $_POST['tail']; $detailedroute = $_POST['detailedroute']; mysql_query("INSERT INTO `zoomdb`.`flightbids` (`dept` ,`dest` ,`flight_id` ,`route` ,`aircraft`, `pid` ,`rank` ,`name` ,`date` ,`time`, `reg`)VALUES ('{$dept}', '{$dest}', '{$fltnum}', '{$route}', '{$aircraft}','{$username}', '{$rank}', '{$name}' ,CURDATE( ) ,CURRENT_TIMESTAMP, $tail )"); $my_t=getdate(date("U")); $textbr = $_SESSION["username"].' '.$_POST['dept'].'/'.$_POST['dest'].' '.$my_t[mday].'.'.$my_t[month].'.'.$my_t[year].'/'.$my_t[hours].''.$my_t[minutes].'<br />FP '.$_POST['fltnum'].' '.$_POST['aircraft'].' '.$_POST['acftreg'].' '.$_SESSION['rank'].' '.$_SESSION['name'].'<br /><br />RMKS<br />'.$rmks.'<br /><br />'.$route.'<br /><br />'.$detailedroute.'<br /><br />METARS<br />Departure<br />Not Available<br /><br />Dest<br />Not Available'; $text = $_SESSION["username"].' '.$_POST['dept'].'/'.$_POST['dest'].' '.$my_t[mday].'.'.$my_t[month].'.'.$my_t[year].'/'.$my_t[hours].''.$my_t[minutes].' FP '.$_POST['fltnum'].' '.$_POST['aircraft'].' '.$_POST['acftreg'].' '.$_SESSION['rank'].' '.$_SESSION['name'].' RMKS '.$rmks.' '.$route.' '.$detailedroute.' METARS Departure Not Available Dest Not Available'; echo '<span class="fpln">'; echo $textbr; echo '<br />'; echo '</span>'; $filename = 'OOM'.$_SESSION["username"].'_'.$_POST['dept'].'-'.$_POST['dest'].'_'.$my_t[mday].' '.$my_t[month].' '.$my_t[year].'_'.$my_t[hours].''.$my_t[minutes].' '.$my_t[minutes].'.txt'; $file = fopen("../ops/fplns/".$filename,"w"); fwrite($file,$text); fclose($file); echo '<br /><a href="fplns/'.$filename.'" target="_blank">Download Flight Plan</a>'; }else{ $fltnum = $_GET['f']; $book_data_sql = mysql_query("select * from flights WHERE flight_num = '{$fltnum}'"); while($book_data = mysql_fetch_array($book_data_sql)){ $dept = $book_data['depticao']; $dest = $book_data['desticao']; $aircraft = $book_data['aircraft']; $route = $book_data['route']; $detailedroute = $book_data['detailed_route']; } $regrand = rand(1,5); ?> <a href="flights.php?p=board">Click Here for Flight Schedule </a></p> <p> </p> <form action="flights.php?p=book" method="POST"> <table width="312" border="0" cellspacing="0" cellpadding="0"> <tr> <td>Flight Number </td> <td><input name="fltnum" type="text" id="fltnum" style="background:#FFFFFF" onfocus="this.style.background='#F0F7FF'" onblur="this.style.background='#ffffff'" value="<?php echo $_GET['f']; ?>" /></td> </tr> <tr> <td width="69%"><label for="dept">Departure (ICAO)</label></td> <td width="31%"><input name="dept" type="text" style="background:#FFFFFF" onfocus="this.style.background='#F0F7FF'" onblur="this.style.background='#ffffff'" value="<?php echo $dept; ?>" maxlength="4" /></td> </tr> <tr> <td>Destination (ICAO </td> <td><input name="dest" type="text" id="dest" style="background:#FFFFFF" onfocus="this.style.background='#F0F7FF'" onblur="this.style.background='#ffffff'" value="<?php echo $dest; ?>" maxlength="4" /></td> </tr> <tr> <td>Aircraft</td> <td> <?php if(!isset($aircraft)){ ?> <select name="aircraft"> <option value="0" selected="selected">Select One</option> <option value="763">767-300</option> <option value="752">757-200</option> <option value="320">A320</option> </select> <?php }else{ echo '<input name="aircraft_disabled" value="'.$aircraft.'" disabled type="text">'; echo '<input name="aircraft" value="'.$aircraft.'" type="hidden">'; } ?> </td> </tr> <tr> <td>Aircraft Registration </td> <td><?php if(!isset($_GET['f'])){ ?> <select name="tail" id="tail"> <option value="0" selected="selected">--Select--</option> <option value="0"> </option> <option value="0">----767----</option> <option value="C-GZUM">C-GZUM</option> <option value="C-GZMM">C-GZMM</option> <option value="C-GZNA">C-GZNA</option> <option value="C-GZNC">C-GZNC</option> <option value="G-UKZM">G-UKZM</option> <option value="0"> </option> <option value="0">----757----</option> <option value="C-GTSN">C-GTSN</option> <option value="0"> </option> <option value="0">---A320---</option> <option value="C-GZUM">C-GZUM</option> </select> <?php }else{ if($aircraft == '763'){ if($regrand == 1){ echo '<input disabled name="reg" value="C-GZUM" type="text" />'; echo '<input name="acftreg" value="C-GZUM" type="hidden" />'; }elseif($regrand == 2){ echo '<input disabled name="reg" value="C-GZMM" type="text" />'; echo '<input name="acftreg" value="C-GZMM" type="hidden" />'; }elseif($regrand == 3){ echo '<input disabled name="reg" value="C-GZNA" type="text" />'; echo '<input name="acftreg" value="C-GZNA" type="hidden" />'; }elseif($regrand == 4){ echo '<input disabled name="reg" value="C-GZNC" type="text" />'; echo '<input name="acftreg" value="C-GZNC" type="hidden" />'; }elseif($regrand == 5){ echo '<input disabled name="reg" value="G-UKZM" type="text" />'; echo '<input name="acftreg" value="G-UKZM" type="hidden" />'; } }elseif($aircraft == '752'){ echo '<input disabled name="reg" value="C-GTSN" type="text" />'; echo '<input name="acftreg" value="C-GTSN" type="hidden" />'; }elseif($aircraft == '320'){ echo '<input disabled name="reg" value="C-GZUM" type="text" />'; echo '<input name="acftreg" value="C-GZUM" type="hidden" />'; }else{ ?> <select name="tail" id="tail"> <option value="0" selected="selected">--Select--</option> <option value="0"> </option> <option value="0">----767----</option> <option value="C-GZUM">C-GZUM</option> <option value="C-GZMM">C-GZMM</option> <option value="C-GZNA">C-GZNA</option> <option value="C-GZNC">C-GZNC</option> <option value="G-UKZM">G-UKZM</option> <option value="0"> </option> <option value="0">----757----</option> <option value="C-GTSN">C-GTSN</option> <option value="0"> </option> <option value="0">---A320---</option> <option value="C-GZUM">C-GZUM</option> </select> <?php } } ?> </td> </tr> <tr> <td colspan="2"> <?php $book_data_sql = mysql_query("select * from flights WHERE flight_num = '{$fltnum}'"); while($book_data = mysql_fetch_array($book_data_sql)){ if(empty($book_data['route'])){ echo '<textarea name="route" rows="5" id="route" style="background:url(../images/route_bkg.jpg) no-repeat; width:100%"></textarea>'; }else{ echo '<input name="detailedroute" type="hidden" value="'.$detailedroute.'" />'; echo '<textarea disabled name="route_disabled" rows="5" id="route" style="width:100%">'.$route.'</textarea>'; echo '<input name="route" type="hidden" value="'.$route.'" />'; }} ?> </td> </tr> <tr> <td colspan="2"><label> <input type="submit" style="width:100%;" class="status_inputs status_blue" name="bid_flight" value="Bid Flight" /> </label></td> </tr> </table> </form> <?php }}} ?> Do you see anything wrong with this? When ever the textarea Route isset, it doesn't upload to the database. It gives no error. It worked before, but I do not know what happened. Link to comment https://forums.phpfreaks.com/topic/85123-solved-mysql-error/ Share on other sites More sharing options...
simcoweb Posted January 9, 2008 Share Posted January 9, 2008 add: or die(mysql_error()); to the end of your query statements to see what the error message is. Link to comment https://forums.phpfreaks.com/topic/85123-solved-mysql-error/#findComment-434231 Share on other sites More sharing options...
maxudaskin Posted January 9, 2008 Author Share Posted January 9, 2008 Does the following mean that there is a problem with my script or the DB? 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 ')' at line 1 Link to comment https://forums.phpfreaks.com/topic/85123-solved-mysql-error/#findComment-434236 Share on other sites More sharing options...
simcoweb Posted January 9, 2008 Share Posted January 9, 2008 You don't need brackets on the WHERE clause variable you're matching against: SELECT * FROM flightbids WHERE pid = '{$pid}' should be: SELECT * FROM flightbids WHERE pid = '$pid' Link to comment https://forums.phpfreaks.com/topic/85123-solved-mysql-error/#findComment-434242 Share on other sites More sharing options...
maxudaskin Posted January 9, 2008 Author Share Posted January 9, 2008 Thanks for the reply, but it didn't do it. Link to comment https://forums.phpfreaks.com/topic/85123-solved-mysql-error/#findComment-434244 Share on other sites More sharing options...
mmarif4u Posted January 9, 2008 Share Posted January 9, 2008 Post your update code... Link to comment https://forums.phpfreaks.com/topic/85123-solved-mysql-error/#findComment-434245 Share on other sites More sharing options...
maxudaskin Posted January 9, 2008 Author Share Posted January 9, 2008 <?php if(!logged_in){ echo 'You cannot access this page as you are not logged in.'; }else{ $pid = $_SESSION['username']; $bidcheckprevsql = mysql_query("SELECT * FROM flightbids WHERE pid = '$pid'"); $bidcheck = mysql_num_rows($bidcheckprevsql); if($bidcheck!=0){ echo 'You cannot bid another flight as you have one already bid. Please file it or delete it.'; $bidcheck = ''; $bidcheckprevsql = ''; }else{ echo $bidcheck; $bidcheck = ''; $bidcheckprevsql = ''; echo $bidcheck; if(isset($_POST['bid_flight'])){ $pid = $_SESSION['username']; $dept = $_POST['dept']; $dest = $_POST['dest']; $fltnum = $_POST['fltnum']; $aircraft = $_POST['aircraft']; $username = $_SESSION['username']; $rank = $_SESSION['rank']; $name = $_SESSION['name']; $route = $_POST['route']; $tail = $_POST['tail']; $detailedroute = $_POST['detailedroute']; mysql_query("INSERT INTO `zoomdb`.`flightbids` (`dept` ,`dest` ,`flight_id` ,`route` ,`aircraft`, `pid` ,`rank` ,`name` ,`date` ,`time`, `reg`)VALUES ('{$dept}', '{$dest}', '{$fltnum}', '{$route}', '{$aircraft}','{$username}', '{$rank}', '{$name}' ,CURDATE( ) ,CURRENT_TIMESTAMP, $tail )") or die(mysql_error()); $my_t=getdate(date("U")); $textbr = $_SESSION["username"].' '.$_POST['dept'].'/'.$_POST['dest'].' '.$my_t[mday].'.'.$my_t[month].'.'.$my_t[year].'/'.$my_t[hours].''.$my_t[minutes].'<br />FP '.$_POST['fltnum'].' '.$_POST['aircraft'].' '.$_POST['acftreg'].' '.$_SESSION['rank'].' '.$_SESSION['name'].'<br /><br />RMKS<br />'.$rmks.'<br /><br />'.$route.'<br /><br />'.$detailedroute.'<br /><br />METARS<br />Departure<br />Not Available<br /><br />Dest<br />Not Available'; $text = $_SESSION["username"].' '.$_POST['dept'].'/'.$_POST['dest'].' '.$my_t[mday].'.'.$my_t[month].'.'.$my_t[year].'/'.$my_t[hours].''.$my_t[minutes].' FP '.$_POST['fltnum'].' '.$_POST['aircraft'].' '.$_POST['acftreg'].' '.$_SESSION['rank'].' '.$_SESSION['name'].' RMKS '.$rmks.' '.$route.' '.$detailedroute.' METARS Departure Not Available Dest Not Available'; echo '<span class="fpln">'; echo $textbr; echo '<br />'; echo '</span>'; $filename = 'OOM'.$_SESSION["username"].'_'.$_POST['dept'].'-'.$_POST['dest'].'_'.$my_t[mday].' '.$my_t[month].' '.$my_t[year].'_'.$my_t[hours].''.$my_t[minutes].' '.$my_t[minutes].'.txt'; $file = fopen("../ops/fplns/".$filename,"w"); fwrite($file,$text); fclose($file); echo '<br /><a href="fplns/'.$filename.'" target="_blank">Download Flight Plan</a>'; }else{ $fltnum = $_GET['f']; $book_data_sql = mysql_query("select * from flights WHERE flight_num = '{$fltnum}'"); while($book_data = mysql_fetch_array($book_data_sql)){ $dept = $book_data['depticao']; $dest = $book_data['desticao']; $aircraft = $book_data['aircraft']; $route = $book_data['route']; $detailedroute = $book_data['detailed_route']; } $regrand = rand(1,5); ?> <a href="flights.php?p=board">Click Here for Flight Schedule </a></p> <p> </p> <form action="flights.php?p=book" method="POST"> <table width="312" border="0" cellspacing="0" cellpadding="0"> <tr> <td>Flight Number </td> <td><input name="fltnum" type="text" id="fltnum" style="background:#FFFFFF" onfocus="this.style.background='#F0F7FF'" onblur="this.style.background='#ffffff'" value="<?php echo $_GET['f']; ?>" /></td> </tr> <tr> <td width="69%"><label for="dept">Departure (ICAO)</label></td> <td width="31%"><input name="dept" type="text" style="background:#FFFFFF" onfocus="this.style.background='#F0F7FF'" onblur="this.style.background='#ffffff'" value="<?php echo $dept; ?>" maxlength="4" /></td> </tr> <tr> <td>Destination (ICAO </td> <td><input name="dest" type="text" id="dest" style="background:#FFFFFF" onfocus="this.style.background='#F0F7FF'" onblur="this.style.background='#ffffff'" value="<?php echo $dest; ?>" maxlength="4" /></td> </tr> <tr> <td>Aircraft</td> <td> <?php if(!isset($aircraft)){ ?> <select name="aircraft"> <option value="0" selected="selected">Select One</option> <option value="763">767-300</option> <option value="752">757-200</option> <option value="320">A320</option> </select> <?php }else{ echo '<input name="aircraft_disabled" value="'.$aircraft.'" disabled type="text">'; echo '<input name="aircraft" value="'.$aircraft.'" type="hidden">'; } ?> </td> </tr> <tr> <td>Aircraft Registration </td> <td><?php if(!isset($_GET['f'])){ ?> <select name="tail" id="tail"> <option value="0" selected="selected">--Select--</option> <option value="0"> </option> <option value="0">----767----</option> <option value="C-GZUM">C-GZUM</option> <option value="C-GZMM">C-GZMM</option> <option value="C-GZNA">C-GZNA</option> <option value="C-GZNC">C-GZNC</option> <option value="G-UKZM">G-UKZM</option> <option value="0"> </option> <option value="0">----757----</option> <option value="C-GTSN">C-GTSN</option> <option value="0"> </option> <option value="0">---A320---</option> <option value="C-GZUM">C-GZUM</option> </select> <?php }else{ if($aircraft == '763'){ if($regrand == 1){ echo '<input disabled name="reg" value="C-GZUM" type="text" />'; echo '<input name="acftreg" value="C-GZUM" type="hidden" />'; }elseif($regrand == 2){ echo '<input disabled name="reg" value="C-GZMM" type="text" />'; echo '<input name="acftreg" value="C-GZMM" type="hidden" />'; }elseif($regrand == 3){ echo '<input disabled name="reg" value="C-GZNA" type="text" />'; echo '<input name="acftreg" value="C-GZNA" type="hidden" />'; }elseif($regrand == 4){ echo '<input disabled name="reg" value="C-GZNC" type="text" />'; echo '<input name="acftreg" value="C-GZNC" type="hidden" />'; }elseif($regrand == 5){ echo '<input disabled name="reg" value="G-UKZM" type="text" />'; echo '<input name="acftreg" value="G-UKZM" type="hidden" />'; } }elseif($aircraft == '752'){ echo '<input disabled name="reg" value="C-GTSN" type="text" />'; echo '<input name="acftreg" value="C-GTSN" type="hidden" />'; }elseif($aircraft == '320'){ echo '<input disabled name="reg" value="C-GZUM" type="text" />'; echo '<input name="acftreg" value="C-GZUM" type="hidden" />'; }else{ ?> <select name="tail" id="tail"> <option value="0" selected="selected">--Select--</option> <option value="0"> </option> <option value="0">----767----</option> <option value="C-GZUM">C-GZUM</option> <option value="C-GZMM">C-GZMM</option> <option value="C-GZNA">C-GZNA</option> <option value="C-GZNC">C-GZNC</option> <option value="G-UKZM">G-UKZM</option> <option value="0"> </option> <option value="0">----757----</option> <option value="C-GTSN">C-GTSN</option> <option value="0"> </option> <option value="0">---A320---</option> <option value="C-GZUM">C-GZUM</option> </select> <?php } } ?> </td> </tr> <tr> <td colspan="2"> <?php $book_data_sql = mysql_query("select * from flights WHERE flight_num = '{$fltnum}'"); while($book_data = mysql_fetch_array($book_data_sql)){ if(empty($book_data['route'])){ echo '<textarea name="route" rows="5" id="route" style="background:url(../images/route_bkg.jpg) no-repeat; width:100%"></textarea>'; }else{ echo '<input name="detailedroute" type="hidden" value="'.$detailedroute.'" />'; echo '<textarea disabled name="route_disabled" rows="5" id="route" style="width:100%">'.$route.'</textarea>'; echo '<input name="route" type="hidden" value="'.$route.'" />'; }} ?> </td> </tr> <tr> <td colspan="2"><label> <input type="submit" style="width:100%;" class="status_inputs status_blue" name="bid_flight" value="Bid Flight" /> </label></td> </tr> </table> </form> <?php }}} } ?> Link to comment https://forums.phpfreaks.com/topic/85123-solved-mysql-error/#findComment-434248 Share on other sites More sharing options...
revraz Posted January 9, 2008 Share Posted January 9, 2008 Do you know which query is returning the error? Link to comment https://forums.phpfreaks.com/topic/85123-solved-mysql-error/#findComment-434249 Share on other sites More sharing options...
mmarif4u Posted January 9, 2008 Share Posted January 9, 2008 Also try to change these: VALUES ('{$dept}', '{$dest}', '{$fltnum}', '{$route}', '{$aircraft}','{$username}', '{$rank}', '{$name}' ,CURDATE( ) ,CURRENT_TIMESTAMP, $tail )") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/85123-solved-mysql-error/#findComment-434251 Share on other sites More sharing options...
maxudaskin Posted January 9, 2008 Author Share Posted January 9, 2008 Do you know which query is returning the error? I am assuming the INSERT INTO flightbids because when the route is not filled out it works and the only query that interacts with that form is the insert into flightbids query. 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 ')' at line 1 Link to comment https://forums.phpfreaks.com/topic/85123-solved-mysql-error/#findComment-434252 Share on other sites More sharing options...
Ken2k7 Posted January 9, 2008 Share Posted January 9, 2008 Is logged_in a constant? Should be $logged_in otherwise. Link to comment https://forums.phpfreaks.com/topic/85123-solved-mysql-error/#findComment-434257 Share on other sites More sharing options...
maxudaskin Posted January 9, 2008 Author Share Posted January 9, 2008 Found the problem... we were all looking for the least obvious answer.... At the end of the specified query, I was missing the quotes around $tail... Link to comment https://forums.phpfreaks.com/topic/85123-solved-mysql-error/#findComment-434262 Share on other sites More sharing options...
revraz Posted January 9, 2008 Share Posted January 9, 2008 Means you changed something. It's helpful to actually post what you changed, then the problem would have been solved easier. It worked before, but I do not know what happened. Link to comment https://forums.phpfreaks.com/topic/85123-solved-mysql-error/#findComment-434265 Share on other sites More sharing options...
maxudaskin Posted January 9, 2008 Author Share Posted January 9, 2008 Means you changed something. It's helpful to actually post what you changed, then the problem would have been solved easier. It worked before, but I do not know what happened. Well... I think it actually means that I should back up my site before I change something... Link to comment https://forums.phpfreaks.com/topic/85123-solved-mysql-error/#findComment-434267 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.