Jump to content

[SOLVED] Whats Wrong?


Sparrow

Recommended Posts

Whenever I run this php script in a web browser I get: error unexpected T_STRING on line 46. 

 

Here is the code. (line 46 is in bold)

 

<?php

session_start();

 

include 'session_checker.php';

session_checker();

 

include 'db.php';

 

//Convert posted info to variables

 

$route_number = $_POST['route_number'];

$username = $_POST['username'];

 

//Get info from flights

 

$sql = "SELECT * FROM flights WHERE route_number = $route_number";

 

$result = mysql_query($sql);

 

$array = mysql_fetch_array($result);

 

//Turn into variables

$type = $array['type'];

$dep_airport = $array['dep_airport'];

$arr_airport = $array['arr_airport'];

$aircraft = $array['aircraft'];

$Rank = $array['Rank'];

$dep_day = $array['dep_day'];

$duration = $array['duration'];

$route_number = $array['route_number'];

 

// Enter info into booked_flights.

$info2 = htmlspecialchars($info);

$sql = mysql_query("INSERT INTO booked_flights (type, dep_airport, arr_airport, aircraft, Rank, dep_day, duration, route_number)

VALUES('$type', '$dep_airport', '$arr_airport', '$aircraft', '$Rank', '$dep_day', '$duration', '$route_number') or die (mysql_error());

 

if(!$sql){

echo 'There has been an error in booking your flight. Please try again.';

 

} else {

$route_number = mysql_insert_id();

 

 

 

//Delete info from flights to prevent double booking.

$sql = "DELETE FROM `flights` WHERE CONVERT(`flights`.`route_number` USING utf8) = '$route_number' LIMIT 1";

 

mysql_close($connection);

 

include 'flight_booked.php';

?>

Link to comment
https://forums.phpfreaks.com/topic/121923-solved-whats-wrong/
Share on other sites

Change this line:

$sql = mysql_query("INSERT INTO booked_flights (type, dep_airport, arr_airport, aircraft, Rank, dep_day, duration, route_number)
	VALUES('$type', '$dep_airport', '$arr_airport', '$aircraft', '$Rank', '$dep_day', '$duration', '$route_number') or die (mysql_error());

 

To this:

 

$sql = mysql_query("INSERT INTO booked_flights (type, dep_airport, arr_airport, aircraft, Rank, dep_day, duration, route_number)
	VALUES('$type', '$dep_airport', '$arr_airport', '$aircraft', '$Rank', '$dep_day', '$duration', '$route_number')") or die (mysql_error());

Link to comment
https://forums.phpfreaks.com/topic/121923-solved-whats-wrong/#findComment-629206
Share on other sites

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.