naveendk.55 Posted September 28, 2011 Share Posted September 28, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/248025-not-able-to-save-data-into-table/ Share on other sites More sharing options...
AyKay47 Posted September 28, 2011 Share Posted September 28, 2011 wrap all of your indices in quotes.. eg $e_name = $_POST['e_name']; $aname = $_POST['aname']; etc... Quote Link to comment https://forums.phpfreaks.com/topic/248025-not-able-to-save-data-into-table/#findComment-1273528 Share on other sites More sharing options...
naveendk.55 Posted September 28, 2011 Author Share Posted September 28, 2011 done that still same error. Quote Link to comment https://forums.phpfreaks.com/topic/248025-not-able-to-save-data-into-table/#findComment-1273535 Share on other sites More sharing options...
awjudd Posted September 28, 2011 Share Posted September 28, 2011 That is a warning/notice and not an error. Did you do it for all of the $_POST variables? ~juddster Quote Link to comment https://forums.phpfreaks.com/topic/248025-not-able-to-save-data-into-table/#findComment-1273538 Share on other sites More sharing options...
AyKay47 Posted September 28, 2011 Share Posted September 28, 2011 you did that for all of your post values shown? if you did, it will not show that error Quote Link to comment https://forums.phpfreaks.com/topic/248025-not-able-to-save-data-into-table/#findComment-1273542 Share on other sites More sharing options...
Pikachu2000 Posted September 28, 2011 Share Posted September 28, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/248025-not-able-to-save-data-into-table/#findComment-1273552 Share on other sites More sharing options...
naveendk.55 Posted September 28, 2011 Author Share Posted September 28, 2011 I put that for all. Yes, the comma after the review date that caused the issue. Thanks for the help. It got resolved. Quote Link to comment https://forums.phpfreaks.com/topic/248025-not-able-to-save-data-into-table/#findComment-1273566 Share on other sites More sharing options...
awjudd Posted September 28, 2011 Share Posted September 28, 2011 Please mark the topic as resolved. ~juddster Quote Link to comment https://forums.phpfreaks.com/topic/248025-not-able-to-save-data-into-table/#findComment-1273603 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.