Jump to content

[SOLVED] MySQL Syntax Problem


PDM

Recommended Posts

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.

 

???

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.