daebat Posted October 6, 2009 Share Posted October 6, 2009 I have a form set up to submit to the database. I am getting this 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 ''asdfasdf', '1', '1', '1', '1', '1', 'button.png', 'apma.jpg', 'akaishi_box.jpg'' at line 1 insert into productimages ('asdfasdf', '1', '1', '1', '1', '1', 'button.png', 'apma.jpg', 'akaishi_box.jpg', '3images.jpg') I can provide the form code if you need that as well. Quote Link to comment https://forums.phpfreaks.com/topic/176718-solved-how-do-i-troubleshoot-this/ Share on other sites More sharing options...
cags Posted October 6, 2009 Share Posted October 6, 2009 The correct format for an INSERT statement is.. INSERT INTO table_name VALUES ('value1', 'value2', 'value3') Bare in mind that if your not inserting all columns you will need to do this... INSERT INTO table_name (column_one, column_2, column4) VALUES ('value1', 'value2', 'value3') Quote Link to comment https://forums.phpfreaks.com/topic/176718-solved-how-do-i-troubleshoot-this/#findComment-931694 Share on other sites More sharing options...
daebat Posted October 6, 2009 Author Share Posted October 6, 2009 this is what I have: <?php $con = mysql_connect("localhost", "theuser", "thepass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_database", $con); $sql = "insert into productimages ('".mysql_real_escape_string($_POST['title'])."', '".mysql_real_escape_string($_POST['chungshi'])."', '".mysql_real_escape_string($_POST['stretchwalker'])."', '".mysql_real_escape_string($_POST['akaishi'])."', '".mysql_real_escape_string($_POST['bellamargiano'])."', '".mysql_real_escape_string($_POST['mbt'])."', '".mysql_real_escape_string($_POST['upjpg'])."', '".mysql_real_escape_string($_POST['uptiff'])."', '".mysql_real_escape_string($_POST['uppng'])."', '".mysql_real_escape_string($_POST['upthumb'])."')"; mysql_query($sql) or die(mysql_error()." <br /> $sql"); echo "The following information was entered into the database<br><br><br>"; echo "<b>Title:</b> $_POST[title]<br>"; echo "Thanks for taking the time to submit your information."; mysql_close($con); ?> Quote Link to comment https://forums.phpfreaks.com/topic/176718-solved-how-do-i-troubleshoot-this/#findComment-931702 Share on other sites More sharing options...
cags Posted October 6, 2009 Share Posted October 6, 2009 So whats the differnce between your insert statement and mine? I'll give you a clue, I already made it bold. Quote Link to comment https://forums.phpfreaks.com/topic/176718-solved-how-do-i-troubleshoot-this/#findComment-931718 Share on other sites More sharing options...
daebat Posted October 6, 2009 Author Share Posted October 6, 2009 Cags, I applaud you. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/176718-solved-how-do-i-troubleshoot-this/#findComment-931793 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.