| | |
PHP MySQL date question.
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Jan 2009
Posts: 11
Reputation:
Solved Threads: 0
New PHP person here..
I am setting up an event registration page. The users must select from two arrival dates for hotel and flights. from my database, I am able to populate a dropdown with the two dates.
I format the date to make it look nice (if i don't, it shows up as 0000-00-00). The problem is, when I try and insert the record, it shows up as zeros anyway.
Below is the snippet from the drop down. If i need to format the date back, should I do it here or what?
Thanks,
I am setting up an event registration page. The users must select from two arrival dates for hotel and flights. from my database, I am able to populate a dropdown with the two dates.
PHP Syntax (Toggle Plain Text)
"SELECT DATE_FORMAT(firstarrival, '%d %M %Y') as newfirsta, DATE_FORMAT(secondarrival, '%d %M %Y') as newseconda, DATE_FORMAT(firstdepart, '%d %M %Y') as newfirstd, DATE_FORMAT(seconddepart, '%d %M %Y') as newsecondd FROM testevent WHERE id = ".$id.""
I format the date to make it look nice (if i don't, it shows up as 0000-00-00). The problem is, when I try and insert the record, it shows up as zeros anyway.
Below is the snippet from the drop down. If i need to format the date back, should I do it here or what?
Thanks,
PHP Syntax (Toggle Plain Text)
<label>Please Select Your Arrival Date:</label> <select name="arrivaldate" id="arrivaldate"> <?php foreach ($traveldates as $traveldate) { ?> <option value="<?php echo htmlentities ($traveldate["newfirsta"]) ?>"><?php echo htmlentities ($traveldate["newfirsta"]) ?> <option value="<?php echo htmlentities ($traveldate["newseconda"]) ?>"><?php echo htmlentities ($traveldate["newseconda"]) ?> <?php } ?> </select>
Last edited by jzimmerman; Jan 16th, 2009 at 1:55 pm.
•
•
Join Date: Jan 2009
Posts: 11
Reputation:
Solved Threads: 0
Thanks...so do I do that with the following line?
?
PHP Syntax (Toggle Plain Text)
$arrivaldate = mysql_real_escape_string($_POST['arrivaldate']);
Yeah, I'd say something like:
would work. Try it out and post back.
php Syntax (Toggle Plain Text)
$arrivaldate = mysql_real_escape_string(strtotime($_POST['arrivaldate']));
Lost time is never found again.
- Benjamin Franklin
- Benjamin Franklin
•
•
Join Date: Jan 2009
Posts: 11
Reputation:
Solved Threads: 0
Well I realized something while working on this. I am retrieving this and storing it in the database as a DATE. It came up with 0000-00-00 even with the last edit and that is what made me look around the database and remember that it is being stored in a date format. If that changes anything, my apologies for omitting that.
Ok, well try this:
php Syntax (Toggle Plain Text)
$arrivaldate = mysql_real_escape_string(date("Y-m-d",strtotime($_POST['arrivaldate']));
Lost time is never found again.
- Benjamin Franklin
- Benjamin Franklin
![]() |
Similar Threads
- php mysql question (PHP)
- Simple PHP Question (PHP)
- it's simple but yet complicated...php and mysql search.. (PHP)
- how can i convert utf-8 to big5 and write into MySQL?? (PHP)
Other Threads in the PHP Forum
- Previous Thread: Msql. Insert data depending on which form field is filled out.
- Next Thread: Master's Degree in Web development?
Views: 1052 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email encode error file files folder form forms function functions google howtowriteathesis href htaccess html image include insert integration ip java javascript joomla jquery limit link login loop mail menu methods mlm mod_rewrite multiple multipletables mysql oop parse paypal pdf php problem provider query radio random recursion regex remote script search select server sessions sms soap source space speed sql structure syntax system table template tutorial update updates upload url validation validator variable video web xml youtube





