不能使用mysql向数据库输入数据


Can't enter data in to the database using mysql

这是将数据输入mysql数据库的php文件。当我运行它时,浏览器显示"连接成功选择成功执行内部文件未插入"。但它不会显示任何错误。并且数据不会插入到数据库中。这段代码有什么问题?* dbConnection.php

  <?php
        $dbhost="localhost";
        $dbuser="root";
        $dbPassword="123";
        $database="medicalcenter";
    $connection = mysqli_connect($dbhost,$dbuser,$dbPassword) or die("unable to connect");
         if($connection){
            echo 'connected successfully ';
        }else{
            echo 'not connected';
        }
        $dbSelect=mysqli_select_db($connection,$database);
        if($dbSelect){
            echo 'selected successfully';
        }else{
            echo 'not selected';
        } 
?>
* insert.php

<?php
    include 'dbConnection.php';
    echo "Executing inside file";
    $firstName = filter_input(INPUT_POST,'firstname');
    $secondName = filter_input(INPUT_POST,'lastname');
    $address1 =filter_input(INPUT_POST,'address1');
    $address2 =filter_input(INPUT_POST,'address2');
    $city =filter_input(INPUT_POST,'city');
    $email =filter_input(INPUT_POST,'email');
    $age =filter_input(INPUT_POST,'age');
    $gender =filter_input(INPUT_POST,'gender');

    $sql= "INSERT INTO    patient(FirstName,LastName,AddressLine1,AddressLine2,City,Email,Age,Gender) VALUES ('$firstName','$secondName','$address1','$address2','$city',$email','$age','$gender')";

    if(mysqli_query($connection,$sql)){
        echo 'Inserted successfully';
    }else{
        echo 'Not Inserted';
    }
    mysqli_close($connection);

  ?>
  $sql= "INSERT INTO    patient(FirstName,LastName,AddressLine1,AddressLine2,City,Email,Age,Gender) VALUES ('$firstName','$secondName','$address1','$address2','$city',$email','$age','$gender')";

检查您的上面一行,您忘记了邮件前的',请检查下面一行。希望它能帮到你。

$sql= "INSERT INTO    patient(FirstName,LastName,AddressLine1,AddressLine2,City,Email,Age,Gender) VALUES ('$firstName','$secondName','$address1','$address2','$city','$email','$age','$gender')";