php脚本没有打开欢迎页面,也没有使用wamp写入数据库

php脚本没有打开欢迎页面,也没有使用wamp写入数据库,php,mysql,Php,Mysql,我无法将任何信息输入我的wamp服务器数据库,也不会显示下面的欢迎页面是我的代码。有人能告诉我我做错了什么,或者我的wamp可能配置错误吗 下面是php代码 <? // Test if submit button was pressed if (isset($_POST['sub_button'])) { $fname=$_POST['fname']; $lname=$_POST['lname']; $sex=$_POST['sex']; $addres

我无法将任何信息输入我的wamp服务器数据库,也不会显示下面的欢迎页面是我的代码。有人能告诉我我做错了什么,或者我的wamp可能配置错误吗

下面是php代码

<?
// Test if submit button was pressed
if (isset($_POST['sub_button'])) { 

    $fname=$_POST['fname'];
    $lname=$_POST['lname'];
    $sex=$_POST['sex'];
    $address=$_POST['add'];
    $email=$_POST['e_address'];
    $years=$_POST['n_years'];
    $favSong=$_POST['f_song'];
    // Create the connection to the server
    $db_host="localhost";
    $db_username="root";
    $db_password="";

    $con=mysqli_connect($ db_host, $db_username, $db_passwod); // to connect to the database server

    // to check the connection to the server
    if(mysqli_connect_errno($con)) {
        echo"Failed to connect to my SQL:" .mysqli_connect_errno();// if there is an error this shows up.
    }
    // this selects the database 

    mysqli.select_db($con, 'fan'); // ensure that the database has the same name as your created database.

    //Insert Statement
    //Values of fname, lname etc is the exact name spelling from the html file.
    //Values of $title $fname are the values from the php which stores the variables name.
    $sql="INSERT INTO information(fname, lname, sex, add, e_address, n_years, f_song)
            VALUES('$fname','$lname','$sex','$address','$email','$years','$favSong')";
    //Check if insert successful.
    if(mysqli_query($con, $sql)) {
        header("Location:welcome.html");
        mysqli_close($con);
    }
    else
    {
        echo "Error;".mysqli_error($con);
    }

}//closing the "IF isset" statement.

//php closing.
?>

反复查看我的代码后,我发现我丢失了

正确代码

相反,我有


您的apache web服务器启动了吗?您能否发布wamp/panel应用程序的打印件,在其中显示其服务的状态?请将您的
mysqli\u close
放在重定向标题之前。并尝试在冒号和
welcome.html
@MarceloBezerra之间添加一个空格,我该怎么做?我是新来的server@iamsleepy我试过你的方法,但仍然不起作用