我的网站上有一个注册表单,Error 1054
当有人尝试注册时我会收到。
PHP代码是:
$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);
我将代码放入在线编译器以获得更详细的错误描述,对于这一行:
('$_POST[address1]','$_POST[address2]','$_POST[address3]','$_POST[address4]')";
它给了我以下错误:
语法错误,意外的 t_encapsed 和空格,需要 T_String 或 T_Variable 或 T_num_string。