Welcome to WebmasterWorld Guest from 54.163.34.237

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

MYSQL reoccuring problem

     
4:22 pm on Apr 11, 2004 (gmt 0)

Junior Member

10+ Year Member

joined:Apr 11, 2004
posts:71
votes: 0


i have re-written my code a few times and changed my database and am really confused i keep getting this error
"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 'desc, date_entered) VALUES (0, 'Maths', 'maths.php','this subje. The query was INSERT INTO admin (menu_id, name, link, desc, date_entered) VALUES (0, 'Maths', 'maths.php','this subject is maths', NOW())." when i try and insert the data into my database

any ideas

4:34 pm on Apr 11, 2004 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 22, 2002
posts:2546
votes: 0


Most likely, it is because you named one of your fields with the reserved word, desc, which stands for descending and is used with the ORDER BY clause.

You can either rename the field or always enclose it in backticks(`) in your queries.

Example:
INSERT INTO admin (menu_id, name, link, `desc`, date_entered)

4:34 pm on Apr 11, 2004 (gmt 0)

New User

10+ Year Member

joined:Feb 23, 2003
posts:27
votes: 0


My best guess wwould be that the column name 'desc' would be a problem, as it is a reserved word in MySql (used for "ORDER BY"). See [dev.mysql.com ] for a list of reserved words.
Hope that helps ...
4:41 pm on Apr 11, 2004 (gmt 0)

Junior Member

10+ Year Member

joined:Apr 11, 2004
posts:71
votes: 0


changed it to description

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 '', date_entered) VALUES (0, 'adasd', 'asdasdasdas','dasdas', NO. The query was INSERT INTO admin (menu_id, name, link, description', date_entered) VALUES (0, 'adasd', 'asdasdasdas','dasdas', NOW()).

4:45 pm on Apr 11, 2004 (gmt 0)

Junior Member

10+ Year Member

joined:Apr 11, 2004
posts:71
votes: 0


and my php is

$query = "INSERT INTO admin (menu_id, name, link, description', date_entered) VALUES (0, '{$_POST['name']}', '{$_POST['link']}','{$_POST['descr']}', NOW())";

and mysql is

Field Type Attributes Null Default Extra Action
sub_id int(10) UNSIGNED No auto_increment
name text No
link text No
date_entered timestamp(14) Yes NULL
description text No
Check All / Uncheck All With selected:

5:00 pm on Apr 11, 2004 (gmt 0)

New User

10+ Year Member

joined:Feb 23, 2003
posts:27
votes: 0


one problem I see is that description has a single quote at the end. I reckon it should be completely without any quotes.
5:05 pm on Apr 11, 2004 (gmt 0)

Junior Member

10+ Year Member

joined:Apr 11, 2004
posts:71
votes: 0


cheers for that guys it works
woo hooo
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members