Jump to content

I need help on MySQL!!!


koulaid

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>
Link to comment
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]
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.