无法将任何信息输入到我的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.
?>

===============>>#1 票数:0 已采纳

一遍又一遍地查看我的代码后,我发现我不见了

正确的代码<?php
?>
<?php
?>

相反,我有

<?
?>

  ask by user3552721 translate from so

未解决问题?本站智能推荐: