Jump to content


Photo

I need help on MySQL!!!


  • Please log in to reply
3 replies to this topic

#1 koulaid

koulaid
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 29 April 2006 - 07:59 PM

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>

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 29 April 2006 - 08:07 PM

If blog_id is an auto_increment column use

either

$query = ("INSERT INTO guestbook_entries (title, entry,) VALUES ('{$_POST['title']}', '{$_POST['entry']}'");
or

$query = ("INSERT INTO guestbook_entries (blog_id, title, entry,) VALUES (NULL, '{$_POST['title']}', '{$_POST['entry']}'");

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 koulaid

koulaid
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 30 April 2006 - 05:19 PM

[!--quoteo(post=369952:date=Apr 29 2006, 03:07 PM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Apr 29 2006, 03:07 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
If blog_id is an auto_increment column use

either

$query = ("INSERT INTO guestbook_entries (title, entry,) VALUES ('{$_POST['title']}', '{$_POST['entry']}'");
or

$query = ("INSERT INTO guestbook_entries (blog_id, title, entry,) VALUES (NULL, '{$_POST['title']}', '{$_POST['entry']}'");
[/quote]


it still doesnt werk? i dont know y

#4 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 30 April 2006 - 05:25 PM

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.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users