I am making a web application which allows user to get funds for the project,I have got most part working but I am stuck at one place where the php script returns a positive status code but no data gets inserted into Mysql database. Following is the php script i am using:

Code:

```
<?php
session_start();
if(!isset($_SESSION['username']))
{
    echo "Unauthorised Page Usage Please Relogin to Access All the Page features;";
    header('location:login.html');

}

$sponsor=mysql_real_escape_string($_POST['sponsorid']);
$projectid=mysql_real_escape_string($_POST['projectid']);
$pledge=mysql_real_escape_string($_POST['pledgevalue']);

$servername = "localhost";
$usernam = "root";
$password = "";
$dbname = "project";
$httpStatusCode = 400;
$httpStatusMsg  = 'Incorrect Username or Password';
$protocol=isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0';

$connection=new mysqli($servername,$usernam,$password,$dbname);
if (!$connection) {
    die("Connection failed: " . $connection->connect_error);
} 

$sql1="INSERT INTO `sponsor`(`spon_id`,`project_id`,`spon_amt`,`spon_date_time`) VALUES ('$sponsor','$projectid','$pledge',NOW())";
$result=$connection->query($sql1);
if ($result) {
        $Success=200;
        $httpStatusMsg=mysqli_error($connection);
        header($protocol.' '.$Success.' '.$result);

 } 

    else {
$Success=400;
    $httpStatusMsg=mysqli_error($connection);
    header($protocol.' '.$Success.' '.$httpStatusMsg);
    }
?>

```

Below is the ajax used to post data to a page:

```
   var xhttp = new XMLHttpRequest();
         xhttp.onreadystatechange = function() {
        if (this.readyState === 4) {
            if(this.status===404){
                alert(this.responseText);
                                             }
            if(this.status===200)
            {

            alert("Project backed successfully");
            window.location.reload(true);

                    }

            }
  };    
        xhttp.open("POST", "sponsor.php", true);

        xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        var param= "sponsorid"+"="+ <?php echo json_encode($_SESSION['username']); ?>+"&"+"pledgevalue"+"="+document.getElementById("pledge").value+"&"+"projectid"+"="+<?php echo json_encode($projectid);?>;
        console.log(param);
        xhttp.send(param);

        } 

```

I have cross referenced my sponsor table to make sure that every field is same.The code works fine on my friend`s computer. Please help me

Update: the $sql1 query is giving me Error code:1644 Problem when I ran it in Database (using XAMMP).

Please help.