Copy link to clipboard
Copied
Not sure what's going on here, but its probably something simple, and me missing something obvious...
Basically I have a form to add a record to a database table.
I have two date fields in the table, of the type, Date.
This is my code for adding the record :
// Add columns
$ins_clients->setTable("clients");
$ins_clients->addColumn("name", "STRING_TYPE", "POST", "name");
$ins_clients->addColumn("company", "STRING_TYPE", "POST", "company");
$ins_clients->addColumn("website", "STRING_TYPE", "POST", "website");
$ins_clients->addColumn("tel", "STRING_TYPE", "POST", "tel");
$ins_clients->addColumn("mobile", "STRING_TYPE", "POST", "mobile");
$ins_clients->addColumn("email", "STRING_TYPE", "POST", "email");
$ins_clients->addColumn("enquirydate", "DATE_TYPE", "POST", "enquirydate");
$ins_clients->addColumn("business", "STRING_TYPE", "POST", "business");
$ins_clients->addColumn("future", "STRING_TYPE", "POST", "future");
$ins_clients->addColumn("potential", "STRING_TYPE", "POST", "potential");
$ins_clients->addColumn("callback", "DATE_TYPE", "POST", "callback");
$ins_clients->addColumn("notes", "STRING_TYPE", "POST", "notes");
$ins_clients->setPrimaryKey("ID", "NUMERIC_TYPE");
And these are the form fields for the dates :
<input type="text" name="enquirydate" id="enquirydate" value="<?php echo KT_formatDate($row_rsclients['enquirydate']); ?>" size="32" />
<input type="text" name="callback" id="callback" value="<?php echo KT_formatDate($row_rsclients['callback']); ?>" size="32" />
All of which seems about right.
But even when I enter dates in the format 2010-09-23, all that's being written back to the database is 0000-00-00.
Any ideas where I'm going wrong?
Thanks.
DATE_TYPE is most likely trying to insert syntax for datetime ex. 2010-09-23 08:45:00 Try setting the transaction for date to STRING_TYPE instead of DATE_TYPE example:
$ins_clients->addColumn("enquirydate", "DATE_TYPE", "POST", "enquirydate");
to
$ins_clients->addColumn("enquirydate", "STRING_TYPE", "POST", "enquirydate");
$ins_clients->addColumn("callback", "DATE_TYPE", "POST", "callback");
to
$ins_clients->addColumn("callback", "STRING_TYPE", "POST", "callback");
Copy link to clipboard
Copied
I've never seen the method you're using to modify a table before, so I can only add some speculation.
I'm not familiar with the commands that you're using but it looks like you're trying to create a new table instead of adding a record to a table and that would explain why the database isn't returning the values you're intending - I could be wrong though .
Are you using a MySQL database? If so, try using a different method to add information to the database and see if that leads to some successful results.
Use this method to create a table.
Use this method to insert information into a table.
Good luck!
Copy link to clipboard
Copied
Thanks - it is a mySQL table - I use phpMyAdmin to create the database structure, and I use Adobe Developers Toolbox to create my add / edit record pages.
I've had no problem with that before, and find it a great workflow for easily adding on page validation errors. So given that its just a glitch with the date fields, I'm not sure about reinventing all of that unless I have to.
Copy link to clipboard
Copied
DATE_TYPE is most likely trying to insert syntax for datetime ex. 2010-09-23 08:45:00 Try setting the transaction for date to STRING_TYPE instead of DATE_TYPE example:
$ins_clients->addColumn("enquirydate", "DATE_TYPE", "POST", "enquirydate");
to
$ins_clients->addColumn("enquirydate", "STRING_TYPE", "POST", "enquirydate");
$ins_clients->addColumn("callback", "DATE_TYPE", "POST", "callback");
to
$ins_clients->addColumn("callback", "STRING_TYPE", "POST", "callback");
Copy link to clipboard
Copied
Thank you - that's working now. Dates are a funny thing sometimes!