naveendk.55 Posted September 29, 2011 Share Posted September 29, 2011 Error: "Error while inserting dataYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') VALUES ('', 'kumar', '6541111', 01/01/2011, '01/01/2011',' at line 7". <?php $e_name = $_POST['evaluator_name']; /* data type = text in the table. Also there is one more attribute in the table caled ID with autoincrement */ $aname = $_POST['aname']; /* data type = text */ $sapid = $_POST['sapid']; /* data type = text */ $processing_date = $_POST['processing_date']; /* data type = date */ $review_date = $_POST['review_date']; /* data type = date */ $contact = $_POST['contact_ID']; /* data type = text */ $audit_type = $_POST['audit_type']; /* data type = text */ $case_no = $_POST['case_no']; /* data type = integer */ $product_name1 = $_POST['product_name1']; $product_name2 = $_POST['product_name2']; $product_name3 = $_POST['product_name3']; $product_name4 = $_POST['product_name4']; $product_name5 = $_POST['product_name5']; $product_name6 = $_POST['product_name6']; $product_name7 = $_POST['product_name7']; $product_name8 = $_POST['product_name8']; $product_name9 = $_POST['product_name9']; $product_name10 = $_POST['product_name10']; $product_name11 = $_POST['product_name11']; $product_name12 = $_POST['product_name12']; $product_name13 = $_POST['product_name13']; $product_name14 = $_POST['product_name14']; $product_name16 = $_POST['product_name16']; $Para_A_A1_score = $_POST['Para_A_A1_score']; $Para_A_A2_score = $_POST['Para_A_A2_score']; $Para_A_A3_score = $_POST['Para_A_A3_score']; $Para_A_A4_score = $_POST['Para_A_A4_score']; $Para_A_A5_score = $_POST['Para_A_A5_score']; $Para_A_A6_score = $_POST['Para_A_A6_score']; $Para_A_A1_Comment = $_POST['Para_A_A1_Comment']; $Para_A_A2_Comment = $_POST['Para_A_A2_Comment']; $Para_A_A3_Comment = $_POST['Para_A_A3_Comment']; $Para_A_A4_Comment = $_POST['Para_A_A4_Comment']; $Para_A_A5_Comment = $_POST['Para_A_A5_Comment']; $Para_A_A6_Comment = $_POST['Para_A_A6_Comment']; $query = "INSERT INTO test (e_name, agent_name, userid, processing_date, review_date, "." ". " contact_ID, audit_type, case_no, product_name, duration, errors, "." ". " mark_parameter_A, mark_parameter_B, mark_parameter_C, mark_parameter_D, mark_parameter_E, "." ". " mark_parameter_F, mark_parameter_G, mark_parameter_H, mark_parameter_I, mark_parameter_J, "." ". " Total_Possible, Score, Para_A_A1, Para_A_A2, Para_A_A3, Para_A_A4, Para_A_A5, Para_A_A6, "." ". " Para_A_A1_Comment, Para_A_A2_Comment, Para_A_A3_Comment, Para_A_A4_Comment, Para_A_A5_Comment, "." ". " Para_A_A6_Comment,) VALUES ('{$evaluator_name}', '{$aname}', '{$sapid}', {$processing_date}, {$review_date}, '{$contact_ID}', '{$audit_type}', {$case_no}, '{$product_name1}', '{$product_name2}', {$product_name3}, {$product_name4}, {$product_name5}, {$product_name6}, {$product_name7}, {$product_name8}, {$product_name9}, {$product_name10}, {$product_name11}, {$product_name12}, {$product_name13}, {$product_name14}, {$product_name16}, {$Para_A_A1_score}, {$Para_A_A2_score}, {$Para_A_A3_score}, {$Para_A_A4_score}, {$Para_A_A5_score}, {$Para_A_A6_score}, '{$Para_A_A1_Comment}', '{$Para_A_A2_Comment}', '{$Para_A_A3_Comment}', '{$Para_A_A4_Comment}', '{$Para_A_A5_Comment}', '{$Para_A_A6_Comment}' )"; $result = mysql_query($query) or die("Error while inserting data" . mysql_error()); mysql_close($connection); ?> Quote Link to comment Share on other sites More sharing options...
dougjohnson Posted September 29, 2011 Share Posted September 29, 2011 Para_A_A6_Comment,) That last coma before the ) VALUE should not be there. Quote Link to comment Share on other sites More sharing options...
naveendk.55 Posted September 29, 2011 Author Share Posted September 29, 2011 I removed that and now getting this error: "Error while inserting dataYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' '', '', '', '', '', '' )' at line 15" Line 15 has below code : $product_name2 = $_POST['product_name2']; Quote Link to comment Share on other sites More sharing options...
dougjohnson Posted September 29, 2011 Share Posted September 29, 2011 I'm not sure what your "." "." are in your insert? I've never seen that before?!? Also, what are the "{" "}" for? Try changing your INSERT to: $query = "INSERT INTO test (e_name, agent_name, userid, processing_date, review_date, contact_ID, audit_type, case_no, product_name, duration, errors, mark_parameter_A, mark_parameter_B, mark_parameter_C, mark_parameter_D, mark_parameter_E, mark_parameter_F, mark_parameter_G, mark_parameter_H, mark_parameter_I, mark_parameter_J, Total_Possible, Score, Para_A_A1, Para_A_A2, Para_A_A3, Para_A_A4, Para_A_A5, Para_A_A6, Para_A_A1_Comment, Para_A_A2_Comment, Para_A_A3_Comment, Para_A_A4_Comment, Para_A_A5_Comment, Para_A_A6_Comment) VALUES ($evaluator_name, $aname, $sapid, $processing_date, $review_date, $contact_ID, $audit_type, $case_no, $product_name1, $product_name2, $product_name3, $product_name4, $product_name5, $product_name6, $product_name7, $product_name8, $product_name9, $product_name10, $product_name11, $product_name12, $product_name13, $product_name14, $product_name16, $Para_A_A1_score, $Para_A_A2_score, $Para_A_A3_score, $Para_A_A4_score, $Para_A_A5_score, $Para_A_A6_score, $Para_A_A1_Comment, $Para_A_A2_Comment, $Para_A_A3_Comment, $Para_A_A4_Comment, $Para_A_A5_Comment, $Para_A_A6_Comment )"; You'll need to make sure every field name has a matching value. Quote Link to comment Share on other sites More sharing options...
naveendk.55 Posted September 29, 2011 Author Share Posted September 29, 2011 yes, data types are correct. I think we need to put string values in codes. Instead of that, I used the {} with single codes. Also I tried your suggestions and it didn't help. Quote Link to comment Share on other sites More sharing options...
dougjohnson Posted September 29, 2011 Share Posted September 29, 2011 Let's simplify things and try it. $e_name = $_POST['evaluator_name']; /* data type = text in the table. Also there is one more attribute in the table caled ID with autoincrement */ $aname = $_POST['aname']; /* data type = text */ $sapid = $_POST['sapid']; /* data type = text */ $processing_date = $_POST['processing_date']; /* data type = date */ $review_date = $_POST['review_date']; /* data type = date */ $contact = $_POST['contact_ID']; /* data type = text */ $audit_type = $_POST['audit_type']; /* data type = text */ $case_no = $_POST['case_no']; /* data type = integer */ $product_name1 = $_POST['product_name1']; $product_name2 = $_POST['product_name2']; $product_name3 = $_POST['product_name3']; $product_name4 = $_POST['product_name4']; $product_name5 = $_POST['product_name5']; $product_name6 = $_POST['product_name6']; $product_name7 = $_POST['product_name7']; $product_name8 = $_POST['product_name8']; $product_name9 = $_POST['product_name9']; $product_name10 = $_POST['product_name10']; $product_name11 = $_POST['product_name11']; $product_name12 = $_POST['product_name12']; $product_name13 = $_POST['product_name13']; $product_name14 = $_POST['product_name14']; $product_name16 = $_POST['product_name16']; $Para_A_A1_score = $_POST['Para_A_A1_score']; $Para_A_A2_score = $_POST['Para_A_A2_score']; $Para_A_A3_score = $_POST['Para_A_A3_score']; $Para_A_A4_score = $_POST['Para_A_A4_score']; $Para_A_A5_score = $_POST['Para_A_A5_score']; $Para_A_A6_score = $_POST['Para_A_A6_score']; $Para_A_A1_Comment = $_POST['Para_A_A1_Comment']; $Para_A_A2_Comment = $_POST['Para_A_A2_Comment']; $Para_A_A3_Comment = $_POST['Para_A_A3_Comment']; $Para_A_A4_Comment = $_POST['Para_A_A4_Comment']; $Para_A_A5_Comment = $_POST['Para_A_A5_Comment']; $Para_A_A6_Comment = $_POST['Para_A_A6_Comment']; $query = "INSERT INTO test (e_name, agent_name) VALUES ($evaluator_name, $aname)"; $result = mysql_query($query) or die("Error while inserting data" . mysql_error()); mysql_close($connection); Does it work now? If so, start adding back some of the other field inserts. Quote Link to comment Share on other sites More sharing options...
naveendk.55 Posted September 29, 2011 Author Share Posted September 29, 2011 Upto here it worked. Let me see the remaining code by adding one by one. <?php $e_name = $_POST['e_name']; /* data type = text in the table. Also there is one more attribute in the table caled ID with autoincrement*/ $aname = $_POST['aname']; /* data type = text */ $sapid = $_POST['sapid']; /* data type = text */ $processing_date = $_POST['processing_date']; /* data type = date */ $review_date = $_POST['review_date']; /* data type = date */ $contact = $_POST['contact_ID']; /* data type = text */ $audit_type = $_POST['audit_type']; /* data type = text */ $case_no = $_POST['case_no']; /* data type = integer */ $query = "INSERT INTO test (e_name, agent_name, userid, processing_date, review_date, contact_ID, audit_type, case_no) VALUES ('{$e_name}', '{$aname}', '{$sapid}', '{$processing_date}', '{$review_date}', '{$contact}', '{$audit_type}', {$case_no} )"; $result = mysql_query($query) or die("Error while inserting data". mysql_error()); mysql_close($connection); ?> Quote Link to comment Share on other sites More sharing options...
dougjohnson Posted September 29, 2011 Share Posted September 29, 2011 You're on the right track. Now just start adding fields and testing after each add. Eventually you'll find the field that's causing the problem. It will be painful but worth it:-) I'm out for the rest of the morning. Good luck. Quote Link to comment Share on other sites More sharing options...
fenway Posted September 29, 2011 Share Posted September 29, 2011 OF course, you're missing DB normalization entirely. Quote Link to comment Share on other sites More sharing options...
naveendk.55 Posted September 30, 2011 Author Share Posted September 30, 2011 What is normalization entry and where It should be added.? The error also gets generated once I start adding the last 6 fields starting from $Para_A_A1_Comment.. Any help? Quote Link to comment Share on other sites More sharing options...
dougjohnson Posted September 30, 2011 Share Posted September 30, 2011 Are the fields you're referencing in the INSERT statement in your database "exactly" as you have them typed? Quote Link to comment Share on other sites More sharing options...
fenway Posted September 30, 2011 Share Posted September 30, 2011 Echo the query and the error. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.