Jump to content

Archived

This topic is now archived and is closed to further replies.

koulaid

I need help on MySQL!!!

Recommended Posts

ok im going crazy because i cant fix this problem. some one plz help me


Could 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>

Share this post


Link to post
Share on other sites
If blog_id is an auto_increment column use

either

[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]

Share this post


Link to post
Share on other sites
[!--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 use

either

[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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.