hellomotohello Posted May 14, 2008 Share Posted May 14, 2008 hey guys im very new to php and ive got this code which ive written up but i am getting a error which says : ( ! ) Parse error: syntax error, unexpected $end on line 79. ive looked out for all small errors like semi colons and stuff but jsut cant find anything, im hoping somebody here can just help me figure out what i am doing wrong. ANy help would be very helpful. thanks. here is the code that ive written up. <?php Function DoQuery($query){ $result = mysql_query($query); if(!$result) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die ($message); } return ($result); } Function ListQResult ($label,$result,$FieldNo) { echo "$label <br/>"; echo "----------<br/>" ; while ($row = mysql_fetch_array($result)) { For ($fno=0;$fno<$FieldNo;$fno++) echo " || ". $row[$fno]; echo "<br/>" ; } echo"===========<br/>"; } Function SearchForm() { Echo " <form action='".$_SERVER['PHP_SELF']."'method='GET'> Write a resort name <input name='Resort' type='text'> <input type='submit' Value='submit'> </form>"; Function ShowFlight() { $table_flight="flight"; $ResortName=$_SESSION['Resort']; If (isset($_SESSION['PageNo'])) { $intPageNo=$_SESSION['PageNo']; } else $intPageNo=0; $StartRecord=$intPageNo*10+1; $query2= " SELECT Airline,DepartureDate FROM $table_flight Where DestinationAirport='".$ResortName."' limit ".$StartRecord.",11 "; $flights=DoQuery($query2); ListQResult('Airline and DepartureDate to '.$ResortName, $flights,2); $num_rows = mysql_num_rows($flights); if ($num_rows>10){ echo "<a href='".$_SERVER['PHP_SELF']."?NextPage=1'>next</a>"; } } session_start(); include("connection1.php"); SearchForm(); $table_hotel="hotel"; $query1= " SELECT DISTINCT resort FROM $table_hotel "; $Resorts=DoQuery($query1); ListQResult ('Available Resorts', $Resorts,1); if (isset ($_REQUEST['Resort'])) { $ResortName=$_REQUEST['Resort']; $_SESSION['Resort']= $ResortName; $_SESSION['PageNo']=0; ShowFlight(); } else if (isset($_REQUEST['NextPage'])) { $intPageNo=$_SESSION['PageNo']; $_SESSION['PageNo'] = $intPageNo+1; ShowFlight(); } mysql_close($dbconnection); ?> Link to comment https://forums.phpfreaks.com/topic/105563-need-help-with-some-php-pls/ Share on other sites More sharing options...
conker87 Posted May 14, 2008 Share Posted May 14, 2008 Can you put it in [ code ][/ code ] and highlight line 79 please. Link to comment https://forums.phpfreaks.com/topic/105563-need-help-with-some-php-pls/#findComment-540758 Share on other sites More sharing options...
hellomotohello Posted May 14, 2008 Author Share Posted May 14, 2008 hey conker line 79 is this: ?> so the final line is line 79 Link to comment https://forums.phpfreaks.com/topic/105563-need-help-with-some-php-pls/#findComment-540762 Share on other sites More sharing options...
conker87 Posted May 14, 2008 Share Posted May 14, 2008 You're missing a closing curly bracket somewhere. } I've formatted the code (so I could read it) and it should work ok now <?php Function DoQuery($query) { $result = mysql_query($query); if(!$result) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die ($message); } return ($result); } Function ListQResult ($label,$result,$FieldNo) { echo "$label "; echo "---------- " ; while ($row = mysql_fetch_array($result)) { For ($fno=0;$fno<$FieldNo;$fno++) echo " || ". $row[$fno]; echo " " ; } echo"=========== "; } Function SearchForm() { echo " <form action='".$_SERVER['PHP_SELF']."'method='GET'> Write a resort name <input name='Resort' type='text'> <input type='submit' Value='submit'> </form>"; } Function ShowFlight() { $table_flight="flight"; $ResortName=$_SESSION['Resort']; If (isset($_SESSION['PageNo'])) { $intPageNo=$_SESSION['PageNo']; } else $intPageNo=0; $StartRecord=$intPageNo*10+1; $query2= " SELECT Airline,DepartureDate FROM $table_flight Where DestinationAirport='".$ResortName."' limit ".$StartRecord.",11 "; $flights=DoQuery($query2); ListQResult('Airline and DepartureDate to '.$ResortName, $flights,2); $num_rows = mysql_num_rows($flights); if ($num_rows>10) { echo "<a href='".$_SERVER['PHP_SELF']."?NextPage=1'>next[/url]"; } } session_start(); include("connection1.php"); SearchForm(); $table_hotel="hotel"; $query1= " SELECT DISTINCT resort FROM $table_hotel "; $Resorts=DoQuery($query1); ListQResult ('Available Resorts', $Resorts,1); if (isset ($_REQUEST['Resort'])) { $ResortName=$_REQUEST['Resort']; $_SESSION['Resort']= $ResortName; $_SESSION['PageNo']=0; ShowFlight(); } else if (isset($_REQUEST['NextPage'])) { $intPageNo=$_SESSION['PageNo']; $_SESSION['PageNo'] = $intPageNo+1; ShowFlight(); } mysql_close($dbconnection); ?> Link to comment https://forums.phpfreaks.com/topic/105563-need-help-with-some-php-pls/#findComment-540787 Share on other sites More sharing options...
hellomotohello Posted May 14, 2008 Author Share Posted May 14, 2008 hey conkey dude thanks it works what was i missing out lol. another issue i got is that i get the information from the database but its just listed like this: Available Resorts ---------- || Istanbul || Izmir || Bodrum || Antalya =========== Airline and DepartureDate to istanbul ---------- || British Airways || 2008-01-14 || British Airways || 2008-01-21 || British Airways || 2008-01-28 || British Airways || 2008-02-04 || British Airways || 2008-02-11 || British Airways || 2008-02-18 || British Airways || 2008-02-25 || British Airways || 2008-03-03 || British Airways || 2008-03-10 || British Airways || how can i get this into a table form. any help wud be good thanks Link to comment https://forums.phpfreaks.com/topic/105563-need-help-with-some-php-pls/#findComment-540816 Share on other sites More sharing options...
conker87 Posted May 14, 2008 Share Posted May 14, 2008 It looks like you'll have to change the function ListQResult to your own formatting. Link to comment https://forums.phpfreaks.com/topic/105563-need-help-with-some-php-pls/#findComment-540820 Share on other sites More sharing options...
hellomotohello Posted May 14, 2008 Author Share Posted May 14, 2008 ok thanks i dont know alot on php im a very new to this, i just want it in a simple table so can u help me do this i dunno where to start. thanks again conker. u rock!!! Link to comment https://forums.phpfreaks.com/topic/105563-need-help-with-some-php-pls/#findComment-540846 Share on other sites More sharing options...
hellomotohello Posted May 14, 2008 Author Share Posted May 14, 2008 hey guys ive been trying to make this table since last 4 hours im really stuck can any1 help me ? Link to comment https://forums.phpfreaks.com/topic/105563-need-help-with-some-php-pls/#findComment-541011 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.