在sql中失败的insert语句

Below is the section of my code which is causing me problems:

$usertype = $_POST['usertype'];
if ($usertype == "Administration") {

?>

<script type='text/javascript'>
window.onload = promptMessage;

function promptMessage() {

    var x = 38773;

    var code = prompt('Enter the administration code you have been given:', 'Enter code here');

    if (code == x) {
        alert("Administration code accepted");

    } else {
        var secondcode = prompt('The code you have entered is inccorect', 'Enter correct code here or change Usertype');
        if (secondcode == x) {
            alert("Administration code accepted");
        } else {
            location.href = 'AdminCodeFail.html';
        }
    }
}  
</script>
<?php
$con = mysqli_connect("localhost:3306", "root", "***********", "systemone");

$sql = "INSERT INTO completeinfo (FirstName, Surname, UniID, 
                                       HouseNumber, AddressLineOne, AddressLineTwo, City, 
                                       PostCode, County, PhoneNumber, Email, Username, 
                                       Password, UserType)
                                       VALUES
                                       ('$_POST[firstname]','$_POST[surname]','$_POST[uniid]',
                                       '$_POST[housenumber]','$_POST[addresslineone]',
                                       '$_POST[addresslinetwo]','$_POST[city]','$_POST[postcode]',
                                       '$_POST[county]','$_POST[contactnumber]','$_POST[email]',
                                       '$_POST[username]','$_POST[password]','$_POST[usertype]')";

if (!mysqli_query($con, $sql)) {
    die('Error: ' . mysqli_error($con));
} else {
    header("Location:SignUpComplete.html");
}

The problem I'm having is that the insert query is just not working. The query fails to insert any data into the database and I am at a loss as to why. The connection to the database is working fine and I'm receiving no errors when testing the query itself. So why isn't the query functioning?

Add

error_reporting(E_ALL);
ini_set('display_errors', '1');

after your code and it will give you more descriptive errors as to why the query is failing.

  1. You can't have array variables in double quotes like this:

    $string = "hello $array['index'] world!";
    

    They must be:

    $string = "hello {$array['index']} world!";
    
  2. Your code has SQL injection vulnerabilities up the wazoo. I strongly suggest reading: How can I prevent SQL injection in PHP?

How should I write PHP $_POST vars in a mysql_query function?

this is your error and this type of question has already been answered.

use

. mysql_real_escape_string to pop out of the string and recognize a value

LOOK AT THE LINK... it will help :)