Jump to content

not able to save data into table


naveendk.55

Recommended Posts

I'm trying to send the details to database and getting the below error.

 

Notice: Use of undefined constant e_name - assumed 'e_name' in C:\wamp\www\ggg\testing.php on line 6

 


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

?> 

Then below I got 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 'contact_ID, audit_type, case_no) VALUES ('', '', '', '', '', '', '', )' at line 1 

Link to comment
Share on other sites

There's no comma between review_date and contact_ID in the query string. You're also allowing that code to run without checking whether the form has been submitted, which will cause undefined variable warnings, and probably empty records to be inserted in your database.

Link to comment
Share on other sites

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.