close ad
Help us test the new Databridge BETA with MySQLi support
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

DataAssist datepicker date to db help needed

Thread began 3/20/2012 8:05 pm by jurinski334466 | Last modified 3/25/2012 11:22 am by jurinski334466 | 3639 views | 8 replies |

jurinski334466

DataAssist datepicker date to db help needed

Hi,
I need help inserting the date from a date picker created by a function. The function creates three dropdowns (month, day, year), but no matter what I try the mysql date remains 0000-00-00 in the database.

A group of older adults will use the datepicker in forms and want this style of datepicker because it's easy to use and read. I want to avoid using javascript or jquery because it adds another layer of code to the page that I (as a volunteer) don't have the time or experience to understand.

I have tried to combine the variables into one variable, tried to reformat the date variables as a mysql formated date, tried rearranging the code blocks, tried to ensure all the variables and code names matched, tried putting different values into the $WA_fieldValuesStr row, and tried solutions from the WA forum and Google. My level of knowledge about what I'm doing is limited and my understanding appears to be dropping by the minute.

The page I'm working on just has the datepicker on it because I want to get the datepicker working before adding it to larger forms. I used the WA Insert Single Record to create the insert. The insert appears to work---when the form submits the database shows a new row of 0000-00-00 and the page redirects to the results page. However, I can't capture the newly selected date to correctly reenter the date into mysql when the form submits.

The database table (datepicker) has two columns: an auto-incrementing ID column DatePickerID (small int, length 3, key) and a date column DatePicked (date, NOT NULL). The date needs to be NOT NULL because the forms will be referenced to, and searched by date. I couldn't find an explanation of how the $WA_columnTypesStr = row works to check that row in the insert form.

I hope that someone at WA might be able to take a look at my files and lead me out of the woods. I enclosed both the date picker and the results page in the zip file. The files are working copies before I tried different code changes. Thank you for your time and attention.

Sign in to reply to this post

Jason ByrnesWebAssist

the mysql database date column expects to receive the date formatted as yyyy-mm-dd. you will reformat the selections that where made to that format.


to do this:
1) make sure the value of the Year select list is a 4 digit year:
<option value="1990">1990</option>

2) make sure the value of the Month select list is the 2 digit month, not the month name:
<option value="01">January</option>

3) make sure the value of the day select list is the 2 digit day number:
<option value="01">1</option>

4) add a hidden form element to the page, but don't set a value for it.

5) add code to line 1 of the page to format the date, assuming the form element names are "year", "month", "day", "fullDate" (hidden element), the code to use would look like this:

php:
<?php if($_SERVER['REQUEST_METHOD'] == "POST"$_POST["fullDate"] = date("Y-m-d"strtotime($_POST["year"]."/".$_POST["month"]."/".$_POST["day"])); ?>



6) in the insert record behavior, bind the date column to the fullDate hidden element which will contain the formatted date.

Sign in to reply to this post

jurinski334466

Thanks for your reply, Jason.
Unfortunately, even with your great instructions I'm still not capturing the values and getting them into mysql. I'm getting a lot of:

"Notice: Undefined index:",
yearmonthday1969-12-31,
Undefined offset: 1 (I think that maybe related to this line? if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):""; ),
Column 'DatePicked' cannot be null,

messages and nothing going into mysql.

I tried different variations of the variables (Y, Year, year, currentYear, m, Month, month etc.} and the page no longer inserts, not even 0000-00-00

I'm sorry, but could you tell my where you made the <option> additions to make this thing work? Would you please give this another go at getting this to work? Many thanks!

Attached Files
datepicker2.php.zip
Sign in to reply to this post

Jason ByrnesWebAssist

your date picker creates the form elements form you as:
DATEPICKEDMonth
DATEPICKEDDay
DATEPICKEDYear


so change the code i provided before to use those form element names instead:

php:
<?php if($_SERVER['REQUEST_METHOD'] == "POST"$_POST["fullDate"] = date("Y-m-d"strtotime($_POST["DATEPICKEDYear"]."/".$_POST["DATEPICKEDMonth"]."/".$_POST["DATEPICKEDDay"])); ?>
Sign in to reply to this post

jurinski334466

Thank you again, Jason.
Your response was a pleasant surprise as I didn't expect to get a reply until Thursday at the soonest. I appreciate your midnight oil solution.

With your helpful instructions I successfully inserted the date into mysql using Dreamweaver's insert record behavior, but I still can't add a date using WA's insert single record behavior. When the WA insert submits I get this response:

Notice: Undefined offset: 1 in ../webassist/database_management/wa_appbuilder_php.php on line 133
Column 'DatePicked' cannot be null.
(I shortened the url.)

I deleted the MacFileCache and applied the DA library fix, but these changes didn't make any difference---I still get the same result. I need to add the datepicker to larger forms and want to use the WA Wizard to create the files.

I enclosed files of the working DW insert and the non-working WA insert in the hope that you would please look the files over and see whether you can spot what I'm doing wrong. I think we are very close to getting everything working, which is a major relief for me.

On a tangent: On the WA single record insert form, why does the form not have a way to browse for a session variable?

Thank you for your patience.

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

Jason ByrnesWebAssist

the error you are getting is occurring because you have bound the DatePickerID column in the database to the WADAInsertRecordID form element, which does not have a value.

the DatePickerID column in the database should be set to auto increment, you should not be binding that column in the insert behavior, you should let the database give it a value.

"On a tangent: On the WA single record insert form, why does the form not have a way to browse for a session variable? "

it does, if you click the lightning bolt icon, you can expand the session collection of the bindings panel and select any session bindings that have been defined.

Sign in to reply to this post

jurinski334466

Thank you for quickly solving what I've spent an embarrassing amount of time trying to figure out myself! It all seems so, um, obvious now that I know how all the pieces fit together. Now I can move on and finish the project, so you've made many people happy today.

"On a tangent: On the WA single record insert form, why does the form not have a way to browse for a session variable? "

"it does, if you click the lightning bolt icon, you can expand the session collection of the bindings panel and select any session bindings that have been defined."

Oops, yes, the binding panel does. However, if you'd switched on your extra-ordinary mind reading powers, you'd know I was thinking about the general panel where the form asks for the name of the session variable. I guess I expected that either the bindings panel would auto-fill the session variable name on the general panel or that I could enter a new name or browse for an existing name on the general panel instead of flipping between the two panels to complete the form. But, what do I know...?

Thank you very much for all your help.

Sign in to reply to this post

Jason ByrnesWebAssist

Sorry, guess i had turned off mind reading...


In the session variable section of the first step of the insert wizard, it does auto populate the name of the session variable using the name of the Key Column. if you want to use a different name, you can enter it manually,

Sign in to reply to this post

jurinski334466

Hmm...my insert wizard doesn't appear to be as accommodating as yours. It doesn't seem to remember how to auto-populate.

Well, my mind reading capabilities rarely turn on---and especially never when I could have actually used them...

Thanks again!

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...