Jump to content

Need Help With Some PHP PLS!!!!!


hellomotohello

Recommended Posts

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

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);

?>

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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.