Link to home
Start Free TrialLog in
Avatar of Member_2_4768634
Member_2_4768634

asked on

How to save the date correctly

Hello!

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

Thank´s!
kunden.txt
kundenDetails.txt
Avatar of Jones911
Jones911

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?
Avatar of Member_2_4768634

ASKER

In which Line 401? I have nowhere so much lines.
No, i´m not sure if the php code is correct.

Thank´s!
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.
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

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

Exactly.
No information are stored in testFile.txt after trying to define a date in the popup.
ASKER CERTIFIED SOLUTION
Avatar of Jones911
Jones911

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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!!
You was very patient with me!
Change:  <mx:DateField id="dw_datum" formatString="YYYY-MM-DD"/>

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

That should do it.
Thank´s!