这是我的etaNavServer.php
文件。这些是我必须插入数据库的值。我的表名是user
,数据库名是srilanka
,这些是我必须插入的值。
<?php if(isset($_POST['continue']))
{
$eta_type = $_POST['eta_type'];
$lastname = $_POST['lastname'];
$firstname = $_POST['firstname'];
$title1=$_POST['title1'];
$sql="INSERT INTO user(applicationtype,surname,givenname,title,) VALUES
('$eta_type','$lastname','$firstname','$title1')";
$query = mysqli_query($con, $sql);
if($query){
echo "<h4 style='color:green'>Services Added Successfully.</h4>";
}
else
{
echo "Failed";
}
}
connection.php
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "srilanka";
$con = new mysqli($servername, $username, $password, $dbname);
?>
答案 0 :(得分:1)
中有语法错误
$sql="INSERT INTO user(applicationtype,surname,givenname,title,) VALUES
('$eta_type','$lastname','$firstname','$title1')";
在标题
之后删除额外的,
$sql="INSERT INTO user(applicationtype,surname,givenname,title) VALUES
('$eta_type','$lastname','$firstname','$title1')";
注意:您只有关闭大括号}
,假设这只是一个错误
修改强>
$query = mysqli_query($con, $sql) or die(mysqli_error($con));