koulaid Posted April 29, 2006 Share Posted April 29, 2006 ok im going crazy because i cant fix this problem. some one plz help meCould not add the entry because: 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 ') VALUES (0, '', ''' at line 1. The query was INSERT INTO guestbook_entries (blog_id, title, entry,) VALUES (0, '', ''.this is the script$query = ("INSERT INTO guestbook_entries (blog_id, title, entry,) VALUES (0, '{$_POST['title']}', '{$_POST['entry']}'");if (@mysql_query ($query)){ print '<p>The guestbook entry has been added</p>';}else{ print "<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>";}mysql_close(); }// Displaying the form?><form action="MySQL.php" method="POST"><p>Entry Title: <input type="text" name="title" size="40" value="<?=$_POST['title']?>" maxsize="100" /></p><p>Entry Text: <input type="text" name="entry" columns="40" rows="5" value="<?=$_POST['entry']?>"></p><input type="submit" name="submit" value="Add Entry" /></form> Quote Link to comment Share on other sites More sharing options...
Barand Posted April 29, 2006 Share Posted April 29, 2006 If blog_id is an auto_increment column useeither[code]$query = ("INSERT INTO guestbook_entries (title, entry,) VALUES ('{$_POST['title']}', '{$_POST['entry']}'");[/code]or[code]$query = ("INSERT INTO guestbook_entries (blog_id, title, entry,) VALUES (NULL, '{$_POST['title']}', '{$_POST['entry']}'");[/code] Quote Link to comment Share on other sites More sharing options...
koulaid Posted April 30, 2006 Author Share Posted April 30, 2006 [!--quoteo(post=369952:date=Apr 29 2006, 03:07 PM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Apr 29 2006, 03:07 PM) [snapback]369952[/snapback][/div][div class=\'quotemain\'][!--quotec--]If blog_id is an auto_increment column useeither[code]$query = ("INSERT INTO guestbook_entries (title, entry,) VALUES ('{$_POST['title']}', '{$_POST['entry']}'");[/code]or[code]$query = ("INSERT INTO guestbook_entries (blog_id, title, entry,) VALUES (NULL, '{$_POST['title']}', '{$_POST['entry']}'");[/code][/quote]it still doesnt werk? i dont know y Quote Link to comment Share on other sites More sharing options...
toplay Posted April 30, 2006 Share Posted April 30, 2006 Change this part:, entry,)to this:, entry)Remove the comma after the entry column name.When posting, please don't just say it doesn't work. Always list the exact error and the query.Thanks. 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.