stormx Posted October 30, 2008 Share Posted October 30, 2008 Hey guys, I keep getting an insert error on this: <?php if($_POST['send']) { $name = mysql_real_escape_string($_POST['field_3']); $contactnum = mysql_real_escape_string($_POST['field_4']); $adslnum = mysql_real_escape_string($_POST['field_5']); $address = mysql_real_escape_string($_POST['field_6']); $dslpass = mysql_real_escape_string($_POST['field_8']); $dsluser = mysql_real_escape_string($_POST['field_7']); $speed = mysql_real_escape_string($_POST['field_9']); $workedprev = mysql_real_escape_string($_POST['field_10']); $prob_desc = mysql_real_escape_string($_POST['field_12']); $dial_tone = mysql_real_escape_string($_POST['field_15']); $modem_status = mysql_real_escape_string($_POST['field_16']); $speed_test = mysql_real_escape_string($_POST['field_78']); $ping_tests = mysql_real_escape_string($_POST['field_83']); $ticket_body = mysql_real_escape_string($_POST['nt_content']); $modem_type = mysql_real_escape_string($_POST['field_11']); $date = date('l jS \of F Y h:i:s A'); $lenumber = $user['service']; $ticket_id = md5(uniqid(rand())); mysql_query("INSERT INTO `tickets`(`contact_name`, `contact_number`, `adsl_number`, `adsl_address`, `dsl_pass`, `dsl_user`, `speed`, `worked_prev`, `dial_tone`, `switched_on`, `speed_test`, `ping_test`, `ticket_body`, `modem_type`, `service_number`, `ticket_status`, `date`, `ticket_id`)VALUES('$name', '$contactnum', '$adslnum', '$address', '$dslpass', '$dsluser', '$speed', '$workedprev', '$prob_desc', '$dial_tone', '$modem_status', '$speed_test', '$ping_tests', '$ticket_body', '$modem_type', '$lenumber, 'Pending', '$date', '1234')") or die("Error Again."); echo '<h2>Your Ticket has been submitted.</h2>'; } ?> I've seached it about 3 times and I cannot find anything that would be putting out the error 'Error Again' Please help, thanks:) Quote Link to comment https://forums.phpfreaks.com/topic/130697-solved-db-insert-issue/ Share on other sites More sharing options...
zenag Posted October 30, 2008 Share Posted October 30, 2008 try to find out what type of error using or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/130697-solved-db-insert-issue/#findComment-678249 Share on other sites More sharing options...
stormx Posted October 30, 2008 Author Share Posted October 30, 2008 I get the error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Pending', 'Thursday 30th of October 2008 01:58:04 AM', '1234')' at line 1 With that code. Quote Link to comment https://forums.phpfreaks.com/topic/130697-solved-db-insert-issue/#findComment-678253 Share on other sites More sharing options...
Mchl Posted October 30, 2008 Share Posted October 30, 2008 You have missing ' just before 'Pending' in the query. Quote Link to comment https://forums.phpfreaks.com/topic/130697-solved-db-insert-issue/#findComment-678255 Share on other sites More sharing options...
stormx Posted October 30, 2008 Author Share Posted October 30, 2008 Oh thanks, works now:) Quote Link to comment https://forums.phpfreaks.com/topic/130697-solved-db-insert-issue/#findComment-678256 Share on other sites More sharing options...
Mchl Posted October 30, 2008 Share Posted October 30, 2008 No problem. Notice, that the error message told you exactly where something went wrong You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Pending', 'Thursday 30th of October 2008 01:58:04 AM', '1234')' at line 1 Whenever you have syntax error near something, it means you screwed the things up somewhere just before that. Quote Link to comment https://forums.phpfreaks.com/topic/130697-solved-db-insert-issue/#findComment-678261 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.