Parse error with adding data from one form to 2 tables!
Posted: Sun Apr 27, 2008 12:58 pm
I can't see the mistake in this code:

<?php
if (isset ($_POST['submit']))
{
$fields = array('username', 'password', 'conf_password', 'FName',
'MName', 'LName', 'Email', 'conf_email', 'Address', 'City',
'State', 'Zipcode', 'Country', 'Hphone', 'Mphone');
foreach($fields as $checked_field)
{
if($_POST['$checked_field'] == '')
{
print "please fill out the $checked_field<br />\n";
}
}
if($_POST['Email'] != $_POST['conf_email']) # the fields match
{
print "Your email input does not match!";
}
if($_POST['password'] != $_POST['conf_password']) # the fields match
{
print "Your password input does not match!";
}
$username=trim(addslahes($_POST['username']));
$password=$_POST['password'];
$FName=trim(addslahes($_POST['FName']));
$MName=trim(addslahes($_POST['MName']));
$LName=trim(addslahes($_POST['LName']));
$Email=$_POST['Email'];
$Address=trim(addslahes($_POST['Address']));
$City=trim(addslahes($_POST['City']));
$State=trim(addslahes($_POST['State']));
$Zipcode=trim(addslahes($_POST['Zipcode']));
$Country=trim(addslahes($_POST['Country']));
$Hphone=trim(addslahes($_POST['Hphone']));
$Mphone=trim(addslahes($_POST['Mphone']));
$host="..............."; // Host name
$username="..............."; // Mysql username
$password="................"; // Mysql password
$db_name=".............."; // Database name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$table_1=".........."; // Table name
$table_2=".............."; // Table name
mysql_query("INSERT INTO $table_1 (userID, username, password,FName, MName, LName,
Email) VALUES (0, '$username', '$password', '$FName', '$MName', '$LName', '$Email')")or
die(mysql_error());
mysql_query("INSERT INTO $table_2 (userID, username, password,FName, MName, LName,
Email, Address, City, State, Zipcode, Country, Hphone, Mphone) VALUES (0,
'$username', '$password', '$FName', '$MName', '$LName', '$Email','$Address',
'$City', '$State', '$Zipcode', '$Country', '$Hphone', '$Mphone')")or
die(mysql_error());
header("location: ******.php");
?>
here is the parse error:
Parse error: syntax error, unexpected $end in /home/............./.....php on line 56
Is there a clear thinker on the board!
Please enlighten me!
Thanx
Batoe
<?php
if (isset ($_POST['submit']))
{
$fields = array('username', 'password', 'conf_password', 'FName',
'MName', 'LName', 'Email', 'conf_email', 'Address', 'City',
'State', 'Zipcode', 'Country', 'Hphone', 'Mphone');
foreach($fields as $checked_field)
{
if($_POST['$checked_field'] == '')
{
print "please fill out the $checked_field<br />\n";
}
}
if($_POST['Email'] != $_POST['conf_email']) # the fields match
{
print "Your email input does not match!";
}
if($_POST['password'] != $_POST['conf_password']) # the fields match
{
print "Your password input does not match!";
}
$username=trim(addslahes($_POST['username']));
$password=$_POST['password'];
$FName=trim(addslahes($_POST['FName']));
$MName=trim(addslahes($_POST['MName']));
$LName=trim(addslahes($_POST['LName']));
$Email=$_POST['Email'];
$Address=trim(addslahes($_POST['Address']));
$City=trim(addslahes($_POST['City']));
$State=trim(addslahes($_POST['State']));
$Zipcode=trim(addslahes($_POST['Zipcode']));
$Country=trim(addslahes($_POST['Country']));
$Hphone=trim(addslahes($_POST['Hphone']));
$Mphone=trim(addslahes($_POST['Mphone']));
$host="..............."; // Host name
$username="..............."; // Mysql username
$password="................"; // Mysql password
$db_name=".............."; // Database name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$table_1=".........."; // Table name
$table_2=".............."; // Table name
mysql_query("INSERT INTO $table_1 (userID, username, password,FName, MName, LName,
Email) VALUES (0, '$username', '$password', '$FName', '$MName', '$LName', '$Email')")or
die(mysql_error());
mysql_query("INSERT INTO $table_2 (userID, username, password,FName, MName, LName,
Email, Address, City, State, Zipcode, Country, Hphone, Mphone) VALUES (0,
'$username', '$password', '$FName', '$MName', '$LName', '$Email','$Address',
'$City', '$State', '$Zipcode', '$Country', '$Hphone', '$Mphone')")or
die(mysql_error());
header("location: ******.php");
?>
here is the parse error:
Parse error: syntax error, unexpected $end in /home/............./.....php on line 56
Is there a clear thinker on the board!
Please enlighten me!
Thanx
Batoe