I have a problem with a date insertion. I am quite new to PHP and mySQL and this is the first problem I have come up against.
I wish for a user to insert events into a form... all the other requests for info will write to their respected areas and have no problem being pulled back out, except the event date...
The code I am using inside the form is this:
<input size="40" name="eventdate"
value="<?php echo date($story['eventdate']);?>">
but the result is always 0000-00-00 as the date entered will not write to the database...
What I need is for the date to be entered in this format so that I can use the date to return a search query so that all entries will display date ascending (or descending).
The Sql $eventdate is set to date, and value is 0000-00-00... the right date can be entered through the phpmyadmin built in calender, but not through the form.
Any help will be received with great thanks,
Fridge
Inserting future date into mysql from a form
Moderator: General Moderators
is $story['eventdate'] a timestamp?
If so
"Y-m-d" could be replaced with the date formatting of your choice.
If so
Code: Select all
<?php echo date("Y-m-d", $story['eventdate']);?>Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Oh.
You should echo $story['eventdate'] to see if it is even set.
You should echo $story['eventdate'] to see if it is even set.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
To catch these type of errors in the future, you should change your .ini file to display all errors (E_ALL) if you have access to it, or you can place the following at the top of the page:
Code: Select all
ini_set('display_errors', 'On');
error_reporting(E_ALL);Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.