Jump to content

same issue. again not able to save data into tables


Recommended Posts

 

 

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);
?>

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'];

 

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.

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.

 

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);

?> 

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.