php date to mysql datetime record update

3 posts by 2 authors in: Forums > CMS Builder
Last Post: December 8, 2011   (RSS)

Re: [ht1080z] php date to mysql datetime record update

By Jason - December 8, 2011

Hi Karls,

I think the problem here is that two of your field names (from and to) are reserved words in MySQL (http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html)

You can get around this by adding ` around your column names like this:

$query = "UPDATE `{$TABLE_PREFIX}accoms` SET
`title` = '".mysql_escape( $_REQUEST['title'] )."',
`type` = '".mysql_escape( $_REQUEST['type'] )."',
`category` = '".mysql_escape( $_REQUEST['category'] )."',
`from` = '".mysql_escape($from)."',
`to` = '".mysql_escape($to)."',
`desc` = '".mysql_escape( $_REQUEST['desc'] )."',
`info` = '".mysql_escape( $_REQUEST['info'] )."',

updatedByUserNum = '".mysql_escape( $CURRENT_USER['num'] )."',
updatedDate = NOW()

WHERE createdByUserNum = '".mysql_escape( $CURRENT_USER['num'] )."'";


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] php date to mysql datetime record update

By ht1080z - December 8, 2011

Thank you Jason! [:)]

reserved words in MySQL... good to know!

Karls