Jump to content

[SOLVED] MySQL / PHP Being Weird :: "Undefined T_VARIABLE"


Recommended Posts

here it is:

 

<?php
$pilot_id = mysql_connect("localhost","user","pass");
if (!$pilot_id)
 {
 die('Could not connect: ' . mysql_error());
 }
 mysql_select_db("cerulean_site", $pilot_id);
 $result = mysql_query("SELECT * FROM pilots ORDER BY pilot_id DESC");
 $row = mysql_fetch_assoc($result); // add this line
 
$pilot_id = $row['pilot_id']+1;
//--------------------------
$first_name=$_POST['first_name'];
$last_name=$_POST['last_name'];
$email=$_POST['email'];
$password=md5($_POST['password']);
$dob=$_POST['dob'];
$personal_location=$_POST['personal_location'];
$personal_country=$_POST['personal_country'];
$public_msn=$_POST['public_msn'];
$public_yim=$_POST['public_yim'];
$public_aim=$_POST['public_aim'];
$public_skype=$_POST['public_skype'];
$public_icq=$_POST['public_icq'];
$public_website=$_POST['public_website'];
$public_avatar=$_POST['public_avatar'];
$public_biography=$_POST['public_biography'];
$public_sagtv=$_POST['public_sagtv'];
$public_real_world_pilot=$_POST['public_real_world_pilot'];
$public_vatsim_controller=$_POST['public_vatsim_controller'];
$public_vatsim=$_POST['public_vatsim'];
$activation_code=substr(str_shuffle("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),0,35);
$hire_date=date("F j, Y");
//-------------------------
$transfer_airline=$_POST['transfer_airline'];
$transfer_proof_link=$_POST['transfer_proof_link'];
$transfer_hours_requested=$_POST['transfer_hours_requested'];

$pilot = mysql_connect("localhost","user","pass");
if (!$pilot)
 {
 die('Could not connect: ' . mysql_error());
 }mysql_select_db("cerulean_site", $pilot);
 $sql="INSERT INTO pilots (pilot_id, first_name, last_name, email, password, date_of_birth, personal_location, personal_country, activation_code, hire_date, public_msn, public_yim, public_aim, public_skype, public_icq, public_website, public_avatar, public_biography, public_sagtv, public_real_world_pilot, public_vatsim_controller, public_vatsim)
VALUES
('$pilot_id','$first_name','$last_name','$email','$password','$dob','$personal_location','$personal_country','$activation_code','$hire_date','$public_msn','$public_yim','$public_aim','$public_skype','$public_icq','$public_website','$public_avatar','$public_biography','$public_sagtv','$public_real_world_pilot','$public_vatsim_controller','$public_vatsim')";

if (!mysql_query($sql,$pilot))
 {
 die('Error: ' . mysql_error());
 }
mysql_close($pilot)

$hour = mysql_connect("localhost","user","pass");
if (!$hour)
 {
 die('Could not connect: ' . mysql_error());
 }mysql_select_db("cerulean_site", $hour);
 $sql="INSERT INTO pilot_hour_transfer (pilot_id, transfer_airline, transfer_proof_link, transfer_hours_requested)
VALUES
('$pilot_id','$transfer_airline','$transfer_proof_link','$transfer_hours_requested')";

if (!mysql_query($sql,$hour))
 {
 die('Error: ' . mysql_error());
 }
mysql_close($hour)

?>

 

I get the following error:

 

Parse error: parse error, unexpected T_VARIABLE on line 173

 

Line 173 is:

 

$hour = mysql_connect("localhost","user","pass");

 

it works fine without the second mysql insert...

 

Thanks in advance

You don't have to connect again. Also you should use a different variable name for the db connection.

<?php
$conn = mysql_connect("localhost","user","pass") or die("Could not connect to the database: " . mysql_error());
mysql_select_db("cerulean_site", $conn);
?>

 

Ken

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.