Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to save the date correctly

Posted on 2009-02-08
15
Medium Priority
?
848 Views
Last Modified: 2013-12-12
Hello!

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

Thank´s!
kunden.txt
kundenDetails.txt
0
Comment
Question by:20one
  • 8
  • 7
15 Comments
 
LVL 19

Expert Comment

by:Jones911
ID: 23585128
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
 

Author Comment

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

Thank´s!
0
 
LVL 19

Expert Comment

by:Jones911
ID: 23585146
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:20one
ID: 23585164
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
 
LVL 19

Expert Comment

by:Jones911
ID: 23585255
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
 

Author Comment

by:20one
ID: 23585290
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
 
LVL 19

Expert Comment

by:Jones911
ID: 23585308
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
 

Author Comment

by:20one
ID: 23585340
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
 
LVL 19

Expert Comment

by:Jones911
ID: 23585365
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
 

Author Comment

by:20one
ID: 23585436
Exactly.
No information are stored in testFile.txt after trying to define a date in the popup.
0
 
LVL 19

Accepted Solution

by:
Jones911 earned 2000 total points
ID: 23585454
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
 

Author Comment

by:20one
ID: 23585486
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
 

Author Closing Comment

by:20one
ID: 31544299
You was very patient with me!
0
 
LVL 19

Expert Comment

by:Jones911
ID: 23585526
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
 

Author Comment

by:20one
ID: 23585553
Thank´s!
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question