PHP脚本没有将数据插入数据库[关闭]

I can not insert into my database, I have tested the $sql on the database and it inserts it no problem, I referenced past code and it looks like it should be working, here is the complete code except the $con info but it does connect to the database, also it returns no errors...

    $Title = $_POST["Title"];
$FName = $_POST["FirstName"];
$LName = $_POST["LastName"];
$Address = $_POST["Address"];
$City = $_POST["City"];
$State = $_POST["State"];
$Zip = $_POST["Zip"];
$Side = $_POST["Side"];
$Relation = $_POST["Relation"];
$tableName = "GuestList";
include 'Config/db_conn.php';

echo "Add to DB<hr><br>";

    $sql= "INSERT INTO $tableName (Title, FirstName, LastName, Address, City, State, Zip, Side, Relation) 
    VALUES ('$Title','$FName','$LName','$Address','$City','$State','$Zip','$Side','$Relation')";

    if (mysqli_query($sql, $con)) {
        echo "Guest Added!";
        echo "<script>window.close();</script>";
    } else {
        echo "FAIL!<br>";
        echo "Guest ".$FName." ".$LName." was not added!!!!<br><br><hr>";
        echo "Error: ".mysqli_error();
        die(mysqli_error());
    }

You have an extra comma in your sql statement add the end of $relation. You're also missing a comma between $city and $state I also recommend using prepared statements.

$sql= "INSERT INTO $tableName (Title, FirstName, LastName, Address, City, State, Zip, Side, Relation) 
    VALUES ('$Title','$FName','$LName','$Address','$City','$State','$Zip','$Side','$Relation')";

Besides the comma's the way you use mysqli_query is wrong.

mysqli_query($sql, $con)

You should switch those variables.

mysqli_query($con, $sql)

As last I recommend reading the PHP manual about mysqli. http://nl1.php.net/manual/en/class.mysqli.php

A comma is missing between '$City''$State':

$sql= "INSERT INTO $tableName (Title, FirstName, LastName, Address, City, State, Zip, Side, Relation) VALUES ('$Title','$FName','$LName','$Address','$City','$State','$Zip','$Side','$Relation')";

You got your arguments backwards for mysql_query:

mixed mysqli_query ( mysqli $link , string $query [, int $resultmode = MYSQLI_STORE_RESULT ] )

You have:

mysqli_query($sql, $con)

You need:

mysqli_query($con, $sql)

mysql_query - PHP

Note: We are all assuming $con is a valid mysqli link since you are not posting the file with it.

Mysqli syntax

mysqli_query($con, $sql)

Thanks to everyone for your help, the problem has been identified; the problem is with 1And1 hosting. They are blocking their own servers from connecting to their database. 1And1 needs help with this one, hopefully they post here so smart people like yourselves can help them out.

Thanks again to everyone!

UPDATE: After they found "nothing" I was able to connect without changing anything. As to the original post and the things people have been posting, the CORRECT and WORKING code snippets are below:

$sql= "INSERT INTO $tableName (Title, FirstName, LastName, Address, City, State, Zip, Side, Relation) 
    VALUES ('$Title','$FName','$LName','$Address','$City','$State','$Zip','$Side','$Relation')";

    if (mysql_query($sql, $con)) {
        echo "Guest Added!";
        echo "<script>window.close();</script>";
    } else {
        echo "FAIL!<br>";
        echo "Guest ".$FName." ".$LName." was not added!!!!<br><br><hr>";
        echo "Error: ".mysql_error();
        die(mysql_error());
    }