Dates coming up blank when inserting new records

3 posts by 2 authors in: Forums > CMS Builder
Last Post: January 23, 2019   (RSS)

By gkornbluth - January 23, 2019

Hi All,

I’m using, the script below (with many text fields left out) to create new records in the table 'listen_live', and it creates a record, but when I look at the record or the database table, dates like createdDate and updatedDate are coming up blank. (0000-00-00 00:00:00 in the database table). I also tried curdate() and CURRENT_TIMESTAMP().

Any thoughts?

Thanks,

Jerry Kornbluth

<?php
mysqlStrictMode(false);
$tablename = 'listen_live';
$colsToValues = array();
$colsToValues['hidden'] = 0;
$colsToValues['createdDate'] = 'NOW()';
$colsToValues['updatedDate'] = 'NOW()';
$colsToValues['time'] = "7:00 to 10:00 PM";
$newRecordNum = mysql_insert($tablename, $colsToValues, true);
?>

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By daniel - January 23, 2019

Hi Jerry,

When setting up your $colsToValues array, if you want to use a MySQL function like "NOW()", the field name needs to be appended with "=" like this:

$colsToValues['createdDate='] = 'NOW()';

Let me know if this fixes the issue, or if you have any other questions!

Thanks,

Daniel
Technical Lead
interactivetools.com

By gkornbluth - January 23, 2019

Hi Daniel,

It's so easy when you know how...

Thanks for the solution.

Best,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php