SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
Thread: Can't insert date to MySQL....
-
Dec 10, 2000, 06:22 #1
- Join Date
- Dec 2000
- Location
- The flat edge of the world
- Posts
- 838
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I've used the following command, is it correct?
<input type="hidden" name="date" value="<?php echo date("d M, Y") ?>">
I was hoping that when the user submits the form, the date in the format of 11 Dec, 2000 would be enter to MySQL, but nothing shows up in the database.
The date field in MySQL is set to VARCHAR (14) not null
-
Dec 10, 2000, 07:05 #2
- Join Date
- Oct 2000
- Posts
- 89
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
if i am not wrong date field in mysql is something like this
year-month-day
2000-02-33
Great Dane
Gokhan ARLI
-
Dec 10, 2000, 10:48 #3
- Join Date
- Aug 2000
- Location
- Silicon Valley
- Posts
- 2,241
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
No, since Robo used VARCHAR(14) and not the date of MySQL
Robo, test the hidden field if it produces the correct format (view src), I believe it is.
If it's the correct format then the problem will be at the part you enter the data into your DB. You should post the code here so we could help.- Son Nguyen
AdSpeed.com - Ad Serving and Ad Management Made Easy
-
Dec 10, 2000, 17:26 #4
- Join Date
- Dec 2000
- Location
- The flat edge of the world
- Posts
- 838
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Got it sorted, seems that the script didn't like where I put the command, shifted the line and it worked...
Now I have another small question, what would I need to do so that I can have a created date? So the date is the first time the recorded is added, and it doesn't change, the function I have now changes everytime someone edits the record.
It's probably really simple, just can't think...
-
Dec 10, 2000, 18:06 #5
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Just don't update the date field each time. I assume you have an inert statement for adding new records that sets the date field to the value of your hidden field, and you have an update statment. In your update statement just don't update that particular field
Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Dec 10, 2000, 19:30 #6
- Join Date
- Dec 2000
- Location
- The flat edge of the world
- Posts
- 838
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks, I knew it's something simple...
Bookmarks