We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

How to save the date correctly

Medium Priority
859 Views
Last Modified: 2013-12-12
Hello!

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

Thank´s!
kunden.txt
kundenDetails.txt
Comment
Watch Question

Commented:
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?

Author

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

Thank´s!

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

Author

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

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

Author

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

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

Author

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.

Commented:
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

Author

Commented:
Exactly.
No information are stored in testFile.txt after trying to define a date in the popup.
Commented:
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.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

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

Author

Commented:
You was very patient with me!

Commented:
Change:  <mx:DateField id="dw_datum" formatString="YYYY-MM-DD"/>

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

That should do it.

Author

Commented:
Thank´s!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.