close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Date Issue Continues

Thread began 3/10/2010 3:49 pm by fabianmacs370894 | Last modified 3/15/2010 5:47 pm by Eric Mittman | 872 views | 8 replies |

fabianmacs370894

Date Issue Continues

I have set up a mysql DB with 2 fields, Name & Date (I have used DATE for column in MySQL DB). I then have used Dataassist to create insert, detail and report pages. When I post a date on insert page using 30-04-2010 it just displays 0000-00-00 on the detail page. I am new to database, PHP and MySQL.

Can anyone help me ASAP as I am very eager to resolve this issue tonight as we have a site going live in the morning!

Many Thanks,

Fabian

Sign in to reply to this post

Eric Mittman

I think the problem you are experiencing is due to the format of the date you are entering. When using a timestamp type of column you should enter the date the same as it is stored in the db, like this:

YYYY-MM-DD hh:mm:ss

If you cannot insert a date using this format you should take a look at the column type in your table. If date is not working for you a timestamp type of column should be used. This will hold the date and time for you. If you have a timestamp type of column and just would like to auto default the column to store the current date and time you could set the default value of the column to CURRENT_TIMESTAMP.

Sign in to reply to this post

fabianmacs370894

Date Problem

Eric,

Thanks for that info. It's not a current timestamp that I can use, the date is based on events later this year. And the time isn't an issue and thats why I use the Date column. If I put in a date 30-07-2010 it posts it to DB 0000-00-00 but if i put in 2010-07-30 it posts it to the DB correctly (as per MySQL spec). My problem is that in the UK we use dd-mm-yyyy format, and thats what the end user will enter into form. I am really stumped at this. Would there be any other solutions?

Many Thanks,

Fabian

Sign in to reply to this post

Eric Mittman

One very cool thing about php is that you can manipulate dates with the date() and strtotime() functions to get the date formatted the way that you would like it.

Where the value is being inserted you can reformat the value entered by the user to match what the db needs. Then on the results, details or any other page where you display the date you can format it to meet the needs of your locale.

Here is an example of how to format the date the the user has entered. In your insert server behavior you are setting the value of the column to your posted element like this:

php:
$_POST['<your date field>']



You can wrap the strtotime and date functions around this value to reformat it like this:

php:
date("Y-m-d", strtotime($_POST['<your date field>']))



This will reformat the date that the user entered to match what your db needs. Then whenever you want to display the date from the db you would do so like this:

php:
date("d-m-Y", strtotime($row_RSrecordset['the_date']))



If you can post back with a copy of the insert, update and details pages I can show you just where you need to make these edits.

Sign in to reply to this post

fabianmacs370894

Date Insert Problems

Eric,

Thanks so much for looking at this issue for me. I have attached a zip with the insert, update and detail page. If you could add the relevant code to display the dates as mentioned that would be great and much appreciated.

Many Thanks,

Fabian

Attached Files
datetest.zip
Sign in to reply to this post

Eric Mittman

I made updates on all of these pages where the date was being used. I noticed though that you named the form element for this Date as well as the column name. You may be able to get away with this but it is a bad idea to use reserved words like date for column names in your db. You can do a quick search to come up with reserved words that you should avoid using in your database tables.

Give the updated pages a try to see if gets you the result you desire, let me know how it goes.

Attached Files
datetestTbl_Results.zip
Sign in to reply to this post

fabianmacs370894

One last update issue

Eric, thanks for sending through that info. I have now got most of it up and running except for the update page. When I insert a new record, all is fine, when I go to the update page the correct date format is showing, problem is when I change the date and submit it again I just get an empty page and it doesn't post the new changes to the DB. Any solutions?

Thanks,

Fabian

Sign in to reply to this post

fabianmacs370894

Sorry didnt include attachment on last message

Eric, thanks for sending through that info. I have now got most of it up and running except for the update page. When I insert a new record, all is fine, when I go to the update page the correct date format is showing, problem is when I change the date and submit it again I just get an empty page and it doesn't post the new changes to the DB. Any solutions?

Thanks,

Fabian

Attachment files attached.

Attached Files
dataassist.zip
Sign in to reply to this post

Eric Mittman

On line 55 of your update page you are using the recordset value, or perhaps I added it like this by mistake. This line of code should be updated to be like this:

php:
$WA_fieldValuesStr = "".((isset($_POST["event_date"]))?date("d-m-Y",*strtotime($_POST["event_date"])):"") ."" . "|" . "".((isset($_POST["event_name"]))?$_POST["event_name"]:"") ."";



This way it will attempt to format the date that the user entered rather than the one from the recordset that might not be valid.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...