PDM Posted July 5, 2007 Share Posted July 5, 2007 Mysql 5 or 3 PHP 3 I have this table jos_content I get a mysql syntax error trying to insert a record Field Type Collation Null Key Default Extra Privileges Comment ---------------- ---------------- ----------------- ------ ------ ------------------- -------------- ------------------------------- ------- id int(11) unsigned (NULL) NO PRI (NULL) auto_increment select,insert,update,references title varchar(100) latin1_swedish_ci NO select,insert,update,references title_alias varchar(100) latin1_swedish_ci NO select,insert,update,references introtext mediumtext latin1_swedish_ci NO select,insert,update,references fulltext mediumtext latin1_swedish_ci NO select,insert,update,references state tinyint(3) (NULL) NO MUL 0 select,insert,update,references sectionid int(11) unsigned (NULL) NO MUL 0 select,insert,update,references mask int(11) unsigned (NULL) NO MUL 0 select,insert,update,references catid int(11) unsigned (NULL) NO MUL 0 select,insert,update,references created datetime (NULL) NO 0000-00-00 00:00:00 select,insert,update,references created_by int(11) unsigned (NULL) NO 0 select,insert,update,references created_by_alias varchar(100) latin1_swedish_ci NO select,insert,update,references modified datetime (NULL) NO 0000-00-00 00:00:00 select,insert,update,references modified_by int(11) unsigned (NULL) NO 0 select,insert,update,references checked_out int(11) unsigned (NULL) NO MUL 0 select,insert,update,references checked_out_time datetime (NULL) NO 0000-00-00 00:00:00 select,insert,update,references publish_up datetime (NULL) NO 0000-00-00 00:00:00 select,insert,update,references publish_down datetime (NULL) NO 0000-00-00 00:00:00 select,insert,update,references images text latin1_swedish_ci NO select,insert,update,references urls text latin1_swedish_ci NO select,insert,update,references attribs text latin1_swedish_ci NO select,insert,update,references version int(11) unsigned (NULL) NO 1 select,insert,update,references parentid int(11) unsigned (NULL) NO 0 select,insert,update,references ordering int(11) (NULL) NO 0 select,insert,update,references metakey text latin1_swedish_ci NO select,insert,update,references metadesc text latin1_swedish_ci NO select,insert,update,references access int(11) unsigned (NULL) NO MUL 0 select,insert,update,references hits int(11) unsigned (NULL) NO 0 Taking values from a form I get a syntax error with the following code $insertSQL = sprintf("INSERT INTO jos_content (title, title_alias, introtext, fulltext, state, sectionid, mask, catid, created, created_by, created_by_alias, modified, modified_by, checked_out, checked_out_time, publish_up, publish_down, images, urls, attribs, version, parentid, ordering, metakey, metadesc, access, hits) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['title'], "text"), GetSQLValueString($_POST['title_alias'], "text"), GetSQLValueString($_POST['introtext'], "text"), GetSQLValueString($_POST['fulltext'], "text"), GetSQLValueString($_POST['state'], "int"), GetSQLValueString($_POST['sectionid'], "int"), GetSQLValueString($_POST['mask'], "int"), GetSQLValueString($_POST['catid'], "int"), GetSQLValueString($_POST['created'], "date"), GetSQLValueString($_POST['created_by'], "int"), GetSQLValueString($_POST['created_by_alias'], "text"), GetSQLValueString($_POST['modified'], "date"), GetSQLValueString($_POST['modified_by'], "int"), GetSQLValueString($_POST['checked_out'], "int"), GetSQLValueString($_POST['checked_out_time'], "date"), GetSQLValueString($_POST['publish_up'], "date"), GetSQLValueString($_POST['publish_down'], "date"), GetSQLValueString($_POST['images'], "text"), GetSQLValueString($_POST['urls'], "text"), GetSQLValueString($_POST['attribs'], "text"), GetSQLValueString($_POST['version'], "int"), GetSQLValueString($_POST['parentid'], "int"), GetSQLValueString($_POST['ordering'], "int"), GetSQLValueString($_POST['metakey'], "text"), GetSQLValueString($_POST['metadesc'], "text"), GetSQLValueString($_POST['access'], "int"), GetSQLValueString($_POST['hits'], "int")); mysql_select_db($database_connNMFFG, $connNMFFG); $Result1 = mysql_query($insertSQL, $connNMFFG) or die(mysql_error()); I use The above style code using DreamWeaver with no problem on hundreds of tables but apparently something to do with jos_content table structure that I don't understand is creating a problem. ??? Quote Link to comment https://forums.phpfreaks.com/topic/58614-solved-mysql-syntax-problem/ Share on other sites More sharing options...
AndyB Posted July 5, 2007 Share Posted July 5, 2007 http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html FULLTEXT is a MySQL reserved word. Avoid using reserved words for naming tables or fields Quote Link to comment https://forums.phpfreaks.com/topic/58614-solved-mysql-syntax-problem/#findComment-290758 Share on other sites More sharing options...
PDM Posted July 6, 2007 Author Share Posted July 6, 2007 Thanks Andy, I missed that!! I wonder how Joomla is getting around that??? This table works in several sites I'm running Joomla on this same server. ??? Quote Link to comment https://forums.phpfreaks.com/topic/58614-solved-mysql-syntax-problem/#findComment-291182 Share on other sites More sharing options...
PDM Posted July 6, 2007 Author Share Posted July 6, 2007 Found it `fulltext` works Thanks again Andy!!! Quote Link to comment https://forums.phpfreaks.com/topic/58614-solved-mysql-syntax-problem/#findComment-291209 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.