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 Quote Link to comment 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 Quote Link to comment 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 ''. Quote Link to comment 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. Quote Link to comment 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. 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.