Can't upload data inot DB with PHP


My PHP code that fails to run, what I have tracked down is lack of permissions but at this point I am not sure, as I checked in mysql that I have permission to insert data, and thats all I try to do! And yes, I know I have removed servername and etc, just in case!


    $servername = "";

    $username = "";

    $password = "";

    $dbname = "";

    $conn = new mysqli($servername, $username, $password, $dbname);

    if ($conn->connect_error){

        die("Connection failed:".$conn->connect_error);


        $DFname = $_POST["DFname"];

        $DLname = $_POST["DLname"];

        $DDiscord = $_POST["DDiscord"];

        $CFname = $_POST["CFname"];

        $CLname = $_POST["CLname"];

        $CoDiscord = $_POST["CoDiscord"];

        $Car = $_POST["options"];

        $sql = "INSERT INTO 'users' ('ID', 'DFname', 'DLname', 'DDiscord', 'CoFname', 'CoLname', 'CoDiscord', 'Car') VALUES('0', '$DFname', '$DLname', '$DDiscord', '$CFname', '$CLname', '$CoDiscord', '$Car')";

        if($conn->query($sql) === TRUE){

            echo "New record created succesfully";

        } else{

            echo "Error:" .$sql."<br>" . $conn->error;




Your file extension if HTML. If you want to use PHP, you will have to change it to .php unless you have set up Hypertext Preprocessor rules in your htaccess.

As for not being able to insert data, what is the sql cluster you are on (eg.
By the way, it is safe to post your sql server, database name and username here. The only person who can actually make use of those here is Admin.


This means the PHP script has crashed. Please enable display_errors to see why.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.