homepage Welcome to WebmasterWorld Guest from 54.242.200.172
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Website
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
MYSQL reoccuring problem
quozt




msg:1312232
 4:22 pm on Apr 11, 2004 (gmt 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

 

Birdman




msg:1312233
 4:34 pm on Apr 11, 2004 (gmt 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)

mapostel




msg:1312234
 4:34 pm on Apr 11, 2004 (gmt 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 ...

quozt




msg:1312235
 4:41 pm on Apr 11, 2004 (gmt 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()).

quozt




msg:1312236
 4:45 pm on Apr 11, 2004 (gmt 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:

mapostel




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

one problem I see is that description has a single quote at the end. I reckon it should be completely without any quotes.

quozt




msg:1312238
 5:05 pm on Apr 11, 2004 (gmt 0)

cheers for that guys it works
woo hooo

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved