查询未将数据插入数据库

$con = mysqli_connect("localhost:3306","root","","travels");
        session_start();
        $emp_id=$_SESSION['emp_id'];
        if(!empty($emp_id))
        {
            if(isset($_POST['Submit1'])) 
            {

                if (mysqli_connect_errno())
                {
                     echo "Failed to connect to MySQL: " . mysqli_connect_error();
                }

               $a_code=$_POST['a_code'];
               $flight_code=$_POST['flight_code'];
               $from_source=$_POST['from_source'];
               $to_dest=$_POST['to_dest'];
               $departure_time=$_POST['departure_time'];
               $arrival_time=$_POST['arrival_time'];
               $seats_available=$_POST['seats_available'];
               $date_of_flight=$_POST['date_of_flight'];

               /*insert into customer_info(fname,lname,pnumber,email) values ('$fname1','$lname1','$pnum1','$email1')*/
               $q="insert into flight_info(a_code,flight_code,from_source,to_dest,departure_time,arrival_time,seats_available,date_of_flight) values ('$a_code','$flight_code','$from_source','$to_dest','$departure_time','$arrival_time','$seats_available','$date_of_flight');";


                if(mysqli_query($con,$q))
                {
                        header('Location:admin-flight_confirmation.php');
                }
               else
               {
                    header('Location:admin-login.php');
               }

            }
        }
        else
        {
            header('Location:admin-login.php');
        }

    ?>

这是PHP代码。数据未插入数据库中。它也不会返回任何错误,所以我无法解决问题。 帮助将不胜感激

评论
  • 行文华
    行文华 回复

    由于我的声誉不是50,所以我无法发表评论,因此您的查询中有一个错误,最后是“;”应该在“之后”之后

    $q="insert into 
    flight_info(a_code,flight_code,from_source,to_dest,departure_time,arrival_time,
    seats_available,date_of_flight) values 
    ('$a_code','$flight_code','$from_source','$to_dest','$departure_time',
    '$arrival_time','$seats_available','$date_of_flight');";   
    
                                                         Above here