I have a registration form on my website and I am getting Error 1054
when a person tries to register.
The PHP code is:
$con=mysql_connect("server","database","password");
// Check connection
if (!$con)
{
echo "Failed to connect to MySQL" . mysql_errno();
}
$sql="INSERT INTO database.table (User_ID, Name, Email, Telephone, MyPassword)
VALUES
(NULL,'$_POST[name]','$_POST[email]','$_POST[telephone]','$_POST[mypassword]')";
if (!mysql_query($sql,$con))
{
die('Error: you fail'.mysql_errno());
}
$User_Id= mysql_insert_id();
$sql="INSERT INTO database.table (Address1, Address2, Address3, Address4)
VALUES
('$_POST[address1]','$_POST[address2]','$_POST[address3]','$_POST[address4]')";
//Inserts address into Address table
if (!mysql_query($sql,$con))
{
die('Error: you failed' . mysql_errno());
}
echo "Thank you for registering with Market Buddy";
mysql_close($con);
I put the code into an online compiler to get a more detailed error description and for this line:
('$_POST[address1]','$_POST[address2]','$_POST[address3]','$_POST[address4]')";
It gives me the following error:
Syntax error, unexpected t_encapsed and whitespace, expecting T_String or T_Variable or T_num_string.