JPark Posted August 25, 2008 Share Posted August 25, 2008 I am having a problem INSERTing data into a mysql table. I am gathering this data from a form on an HTML page which, in turn submits it to a php page that INSERTs it. I can echo my $query but no data gets into the table. Here is the output from my php page: SWAT INSERT Test INSERT INTO csvd (id,serverName,serverDescription,serverType,issueType,incidentDate,downtimeStart, downtimeEnd,totalDowntime,incidentReport,ticketNumber,causeAnalysis) VALUES ('','steps22','MRTS, MWTS','dev','Scheduled Maintenance','08/22/2008','1630','1800', '2 hours, 30 minutes','Incident Report','1234567890','Root Cause Analysis')Thank you for your contribution! And here are snipets from the php code: <? ...snip... $serverName = $_POST['serverName']; //start if loops to match up serverName with serverDescription and serverType if ($serverName == 'steps20') { $serverType = 'software acceptance'; $serverDescription = 'Engenera test'; } elseif ($serverName == 'steps21') { ...snip... else { } $issueType=$_POST['issueType']; $incidentDate=$_POST['incidentDate']; $downtimeStart=$_POST['downtimeStart']; $downtimeEnd=$_POST['downtimeEnd']; $totalDowntime=$_POST['totalDowntime']; $incidentReport=$_POST['incidentReport']; $ticketNumber=$_POST['ticketNumber']; $causeAnalysis=$_POST['causeAnalysis']; mysql_connect(localhost,'<username>','<password>'); @mysql_select_db('esmpd_eapbcalendar') or die( "Unable to select database"); $query = "INSERT INTO csvd (id,serverName,serverDescription,serverType,issueType,incidentDate,downtimeStart, downtimeEnd,totalDowntime,incidentReport,ticketNumber,causeAnalysis) VALUES ('','$serverName','$serverDescription','$serverType','$issueType','$incidentDate', '$downtimeStart','$downtimeEnd','$totalDowntime','$incidentReport','$ticketNumber', '$causeAnalysis')"; mysql_query($query); mysql_close(); echo $query; ?> Thoughts? Suggestions? Corrections? Thanks! Joe Link to comment https://forums.phpfreaks.com/topic/121234-a-problem-inserting-data/ Share on other sites More sharing options...
revraz Posted August 25, 2008 Share Posted August 25, 2008 use mysql_error after your query to see why it failed Link to comment https://forums.phpfreaks.com/topic/121234-a-problem-inserting-data/#findComment-624978 Share on other sites More sharing options...
joquius Posted August 25, 2008 Share Posted August 25, 2008 I usually put in '0' for auto-incremental fields, some versions of MySQL don't like ''. Link to comment https://forums.phpfreaks.com/topic/121234-a-problem-inserting-data/#findComment-624983 Share on other sites More sharing options...
DarkWater Posted August 25, 2008 Share Posted August 25, 2008 You should leave the auto-incrementing field out of the entire query. Link to comment https://forums.phpfreaks.com/topic/121234-a-problem-inserting-data/#findComment-624984 Share on other sites More sharing options...
revraz Posted August 25, 2008 Share Posted August 25, 2008 Or just eliminate it all together. No need to even use it. Link to comment https://forums.phpfreaks.com/topic/121234-a-problem-inserting-data/#findComment-624985 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.