Here is the Table i Created in database...

    CREATE TABLE  `a1878876_uonrm`.`saveproposal` (
    `ID` INT( 20 ) NOT NULL AUTO_INCREMENT ,
    `PI` VARCHAR( 500 ) NOT NULL ,
    `Email` VARCHAR( 200 ) NOT NULL ,
    `RTitle` VARCHAR( 500 ) NOT NULL ,
    `Coauthors` VARCHAR( 500 ) NOT NULL ,
    `ExSummary` VARCHAR( 500 ) NOT NULL ,
    `LReview` VARCHAR( 500 ) NOT NULL ,
    `Objective` VARCHAR( 500 ) NOT NULL ,
    `Methodology` VARCHAR( 500 ) NOT NULL ,
    `EOutput` VARCHAR( 500 ) NOT NULL ,
    `References` VARCHAR( 500 ) NOT NULL ,
    `RDuration` VARCHAR( 500 ) NOT NULL ,
    PRIMARY KEY (  `ID` )
    ) ENGINE = MYISAM COMMENT =  'This Table save the proposals'

Here is the PHP Code to insert data into table.....

     $sqldel = "DELETE FROM saveproposal WHERE PI='$peru' AND RTitle='$title' AND Email='$email'";
     $resdel = mysqli_query($con, $sqldel);   

    $sqls = "INSERT INTO saveproposal (ID, PI, Email, RTitle, Coauthors, ExSummary, LReview, Objective, Methodology, EOutput, References, RDuration) VALUES (NULL, '$peru', '$email', '$title', '$auth', '$eta', '$pta', '$ota', '$mta','$eota','$rta','$rdt');";
    $result = mysqli_query($con,$sqls);

    if($result)
    { 
         header("Location:http://mdskhan.netau.net/subdone.php");
    }else{
            $erro ="$peru,$email,$title,$auth,$eta,$pta,$ota,$mta,$eota,$rta,$rdt";

            echo "Data is:".$erro;

            echo "SQL Query to execute: $sqls";

            die('Invalid query: ' . mysql_error());
    }

Here is the out put i am getting.... Insetead of data insert...

OUTPUT:

Data is: Mohammed Shafakhatullah Khan,shafakhat@unizwa.edu.om,One,Nine,Two,Three,Four,Five,Six,Seven,Eight
SQL Query to execute: INSERT INTO saveproposal (ID, PI, Email, RTitle, Coauthors, ExSummary, LReview, Objective, Methodology, EOutput, References, RDuration) VALUES (NULL, 'Mohammed Shafakhatullah Khan', 'shafakhat@unizwa.edu.om', 'One', 'Nine', 'Two', 'Three', 'Four', 'Five','Six','Seven','Eight');
Invalid query:

Please help me out!!!!!! I don't understand why INSERT QUERY IS NOT WORKING

The problem is in the name of the References field (column) which is a Mysql reserved word and should not be used as a field name. If you still wish to use it as a field name you should enclose it in backticks. I would recommend you change it so you avoid possible errors in future.

$sqls = "INSERT INTO saveproposal (ID, PI, Email, RTitle, Coauthors, ExSummary, LReview, Objective, Methodology, EOutput, `References`, RDuration) VALUES (NULL, '$peru', '$email', '$title', '$auth', '$eta', '$pta', '$ota', '$mta','$eota','$rta','$rdt');";

Se the list of mysql reserved words here.

Thank you very much broj1 you are absolutely correct, i too figured out that thing on the same day as soon as i post it. You are dammn good to trace that really you belive it or not so many did not have solution for this question.

Thanks a lot for your kind help.....

No worries, mate .-) Please mark this as solved. Happy coding in 2015.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.