Variable error

I seem to be staring at a needle in the haystack. I´ve created a PHP form to collect data that I am trying to write to my mySQL database. I continue to get this error everytime I submit the form:

Parse error: syntax error, unexpected T_VARIABLE in /homepages/41/d439316937/htdocs/php/update.php on line 18
I´ve double checked all of the variables and can´t seem to find the problem. Below is the PHP

[php]

update.php <?php $stid = $_POST['stid']; $station = $_POST['station']; $line = $_POST['line']; $con_1 = $_POST['con_1']; // Mysql connect------------- mysql_connect ("db439631507.db.1and1.com", "dbo439631507", "********") or die ('Error ' . mysql_select_db ("db439631507") //Mysql Query----------------THe next line SEEMS TO BE WHERE THE PROBLEM LIES---------------------

$query=“INSERT INTO metro_station (stid, station, line, con_1) VALUES
(‘NULL’,’”.stid."’,’".station."’,’".line."’,’".con_1."’

//Status report------------
mysql_query($query) or die (‘Error updating database’);
echo "Database updated with: “.$stid.” “.$station.” “.$line.”
“.$con_1.”;

?>

[/php]

Table: metro_station
The data fields in mySQL are:
stid
station
line
con_1

I´m new to PHP, and this seems to be an achilles heel. Any help would be appreciated.
Thanks
John

mysql_connect (“db439631507.db.1and1.com”, “dbo439631507”, “")or die ('Error ’ . should be mysql_connect (“db439631507.db.1and1.com”, “dbo439631507”, "”)or die ('Error ');

missing the ; at the end of the db select

$query=“INSERT INTO metro_station (stid, station, line, con_1) VALUES(‘NULL’,”.stid."’,’".station."’,’".line."’,’".con_1."’ should be
$query=“INSERT INTO metro_station (stid, station, line, con_1) VALUES(’$stid.’, ‘$station’, ‘$line’ ,’$con_1’)”;

echo “Database updated with: “.$stid.” “.$station.” “.$line.””.$con_1."; can be changed to
echo “Database updated with: $stid $station $line $con_1.”;

Thanks for such a prompt reply. Unfortunately, even with the corrections, I get the same “Parse error: syntax error, unexpected T_VARIABLE in /homepages/41/d439316937/htdocs/php/update.php on line 18”

Here is the corrected script.
[php]

Update Station.php <?php $stid = $_POST['stid']; $station = $_POST['station']; $line = $_POST['line']; $con_1 = $_POST['con_1']; // Mysql connect------------- mysql_connect ("db439631507.db.1and1.com", "********", "*******") or die ('Error'); mysql_select_db ("db439631507") //Mysql Query---------------- $query="INSERT INTO metro_station (stid, station, line, con_1) VALUES('$stid.','$station','$line','$con_1')"; //Status report------------ mysql_query($query) or die ('Error updating database'); echo "Database updated with: $stid $station $line $con_1."; ?> // // [/php]

On the assumption that the . after VALUES(´$STID … might have been a typo, I tried using it with and without the .

Same results either way.
Thanks again.
John

Your corrected code is still missing the line ending. You also appear to have posted your database credentials.

[php]mysql_select_db (“db439631507”);[/php]

Thanks Matt, It now works perfectly.

Sponsor our Newsletter | Privacy Policy | Terms of Service