我已针对同一错误检查了之前已回答的问题,并尝试应用修复程序。但是,不知怎的,我仍然得到这个错误。我只是想将表单注入我的数据库。我已添加以下代码。
<html>
<body>
<?php
$con = mysqli_connect("localhost","","","registration_db3");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
else
{
echo " Connected To Database. ";
}
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$age = $_POST['age'];
if (isset($sex) && $sex=="female");
if (isset($sex) && $sex=="male");
$email = $_POST['email'];
$chkbox = array('indian', 'italian', 'thai', 'mexican');
if(isset($_POST['submit']))
{ $cuisine = $_POST['cuisine'];
$values = array();
foreach($chkbox as $selection )
{ if(in_array($selection, $cuisine))
{ $selection[ $selection ] = 1; }
else
{ $selection[ $selection ] = 0; }
}
$city = $_POST['city'];
$about = $_POST['about_you'];
if(mysqli_query($con,"INSERT INTO registration_info (first_name, last_name, age, sex, email, city, about_you)
VALUES
('$_POST[first_name]','$_POST[last_name]','$_POST[age]','$_POST[sex]','$_POST[email]','$_POST[city]','$_POST[about_you]')"));
if(mysqli_query($con,"INSERT INTO cuisine (indian, italian, thai, mexican)
VALUES
({$values['indian']}, {$values['italian']}, {$values['thai']}, {$values['mexican']})"));
echo "Registration Completed Successfully.";
?>
<br>
Welcome
<?php
echo $_POST["first_name"];
?>
<br>
All communications to you will be made to
<?php
echo $_POST["email"];
?>
</body>
</html>
答案 0 :(得分:2)
尝试匹配大括号。 if(isset($_POST['submit']))
之后的括号没有和结束对。
答案 1 :(得分:1)
这里有开口支撑:
if(isset($_POST['submit']))
{ $cuisine = $_POST['cuisine'];
$values = array();
但是我看不到结束对