How to save the date correctly

Hello!

How can i save the date correctly in the MYSQL database?

Thank´s!
kunden.txt
kundenDetails.txt
20oneAsked:
Who is Participating?
 
Jones911Commented:
OK then your problem is in flex.

dw_datum.selectedDate change to dw_datum.text

Not sure how well PHP will handle the conversion but worth a go.
0
 
Jones911Commented:
In the

Line 401:  are you sure the value of:  fa_datum.text  is a date at the time you send it to PHP?

Are you sure the save php code is correct?
0
 
20oneAuthor Commented:
In which Line 401? I have nowhere so much lines.
No, i´m not sure if the php code is correct.

Thank´s!
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
Jones911Commented:
kundenDetails is > 400 lines.  That is the file I am talking about.

Hard code a date in PHP and try insert that first.  Perhaps show a snippet of the php code.
0
 
20oneAuthor Commented:
OK, sorry, i have delete some lines ... i don´t need anymore.

fa_datum is another date. i have 3 dates in the userdetails (fa_datum, dw_datum, gebdatum).
I have ask you only for dw_datum, because later it´s the same for me to change the other 2 dates.


<?php
 
define( "DATABASE_SERVER", "localhost" );
define( "DATABASE_USERNAME", "xxx" );
define( "DATABASE_PASSWORD", "xxx" );
define( "DATABASE_NAME", "xxx" );
 
 
$mysql = mysql_connect(DATABASE_SERVER, DATABASE_USERNAME, DATABASE_PASSWORD);
 
mysql_select_db( DATABASE_NAME );
 
 
if (isset($_POST["emailaddress"]) && is_numeric($_POST["userid"])) {
	//mysql_query("INSERT INTO users (emailaddress,username) VALUES('".$_POST["emailaddress"]."','".$_POST["username"]."')");
	mysql_query("UPDATE users SET emailaddress='".$_POST["emailaddress"]."', username='".$_POST["username"]."', usernachname='".$_POST["usernachname"]."', anrede='".$_POST["anrede"]."', plz='".$_POST["plz"]."', ort='".$_POST["ort"]."', strasse='".$_POST["strasse"]."', tel_privat='".$_POST["tel_privat"]."', gebdatum='".$_POST["gebdatum"]."', beruf='".$_POST["beruf"]."', sonstiges='".$_POST["sonstiges"]."', dw_datum='".$_POST["dw_datum"]."', dw_bedienung='".$_POST["dw_bedienung"]."', dw_wickler='".$_POST["dw_wickler"]."', dw_anordnung='".$_POST["dw_anordnung"]."', dw_einwirkzeit='".$_POST["dw_einwirkzeit"]."', dw_nachbehandlung='".$_POST["dw_nachbehandlung"]."', dw_preis='".$_POST["dw_preis"]."', dw_anmerkungen='".$_POST["dw_anmerkungen"]."', fa_datum='".$_POST["fa_datum"]."', fa_bedienung='".$_POST["fa_bedienung"]."', fa_rezeptur='".$_POST["fa_rezeptur"]."', fa_einwirkzeit='".$_POST["fa_einwirkzeit"]."', fa_preis='".$_POST["fa_preis"]."', fa_anmerkungen='".$_POST["fa_anmerkungen"]."', image_url='".$_POST["image_url"]."' WHERE userid=".$_POST["userid"]);
}
 
 
$Query = "SELECT * from users";
$Result = mysql_query( $Query );
 
$Return = "<users>";
 
while ( $User = mysql_fetch_object( $Result ) )
{
$Return .= "<user><userid>".$User->userid."</userid><anrede>".$User->anrede."</anrede><username>".$User->username."</username><usernachname>".$User->usernachname."</usernachname><emailaddress>".$User->emailaddress."</emailaddress><plz>".$User->plz."</plz><ort>".$User->ort."</ort><strasse>".$User->strasse."</strasse><tel_privat>".$User->tel_privat."</tel_privat><gebdatum>".$User->gebdatum."</gebdatum><beruf>".$User->beruf."</beruf><sonstiges>".$User->sonstiges."</sonstiges><dw_datum>".$User->dw_datum."</dw_datum><dw_bedienung>".$User->dw_bedienung."</dw_bedienung><dw_wickler>".$User->dw_wickler."</dw_wickler><dw_anordnung>".$User->dw_anordnung."</dw_anordnung><dw_einwirkzeit>".$User->dw_einwirkzeit."</dw_einwirkzeit><dw_nachbehandlung>".$User->dw_nachbehandlung."</dw_nachbehandlung><dw_preis>".$User->dw_preis."</dw_preis><dw_anmerkungen>".$User->dw_anmerkungen."</dw_anmerkungen><fa_datum>".$User->fa_datum."</fa_datum><fa_bedienung>".$User->fa_bedienung."</fa_bedienung><fa_rezeptur>".$User->fa_rezeptur."</fa_rezeptur><fa_einwirkzeit>".$User->fa_einwirkzeit."</fa_einwirkzeit><fa_preis>".$User->fa_preis."</fa_preis><fa_anmerkungen>".$User->fa_anmerkungen."</fa_anmerkungen><image_url>".$User->image_url."</image_url></user>";
}
$Return .= "</users>";
mysql_free_result( $Result );
print ($Return);
 
?>

Open in new window

0
 
Jones911Commented:
Write this out to a temp file and check the value.  Make sure that a date is actually coming back from flex.  Then we can track backwards through the flex code.
0
 
20oneAuthor Commented:
When i call the php directly in the browser, i get everything back correctly.

1Aichmayr00001974-05-082009-02-08

2009-02-08 ist the date in dw_datum
0
 
Jones911Commented:
So are you having trouble saving or retrieving the date you last reply confuses me?  As you are posting from Flex to PHP I'm not sure how you can call the PHP in the browser?

Write out the date to a temp file before the insert into the database and look if the date is commign from Flex correctly.
0
 
20oneAuthor Commented:
I think both ... In the database are no entries stored in dw_datum, only "NULL".

You can call it by your self:
http://www.moremedia.at/hairbutler/kunden.php

Sorry, i don´t know how to write out the date into a temp.
0
 
Jones911Commented:
OK but then the date in the DB is:   00:00:00 GMT+0100

Now you want to save over that but your update is not working?  


$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $_POST["dw_datum"];
fwrite($fh, $stringData);
fclose($fh);
 
Then inspect testFile.txt and see if a date is comming back from Flex.

Open in new window

0
 
20oneAuthor Commented:
Exactly.
No information are stored in testFile.txt after trying to define a date in the popup.
0
 
20oneAuthor Commented:
Now it works! :) Great! Thank you for your patience.
Please tell how i can change the formatted date from YYYY-MM-DD to DD.MM.YYYY


Thank´s!!
0
 
20oneAuthor Commented:
You was very patient with me!
0
 
Jones911Commented:
Change:  <mx:DateField id="dw_datum" formatString="YYYY-MM-DD"/>

To:  <mx:DateField id="dw_datum" formatString="DD.MM.YYYY"/>

That should do it.
0
 
20oneAuthor Commented:
Thank´s!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.