You are here: Re: Inserting Current date and time into MySQL database using PHP « All PHP « IT news, forums, messages
Re: Inserting Current date and time into MySQL database using PHP

Posted by mpar612 on 08/06/06 18:36

Here might be a dumb question, but what is toppost?

Rik wrote:
> mpar612@gmail.com wrote:
>
> Please don't toppost. Google netiquette.
>
> > MS wrote:
> >> <mpar612@gmail.com> wrote in message
> >> news:1154887476.661483.210720@m73g2000cwd.googlegroups.com...
> >>> Hi everyone,
> >>>
> >>> Pretty new to the forums, PHP and MySQL here. I am having an issue
> >>> inserting the current date and time into a MySQL database using PHP.
> >>>
> >>> Here is my query:
> >>> $db->query('INSERT INTO lounge (isbn, artist_name, album_title,
> >>> release_date, add_date, description, price)
> >>> VALUES (?,?,?,?,?,?)',
> >>> array($_POST['isbn'], $_POST['artist_name'],
> >>> $_POST['album_title'], $_POST['release_date'], curdate(),
> >>> $_POST['description'], $_POST['price']));
> >>>
> >>> My issue is with automatically entering the current date and time
> >>> into the add_date field of the database. I did some searching and
> >>> tried the curdate() function in MySQL and that did not work. This
> >>> is not a date that is input by the user. I would like the date to
> >>> be automatically added to the database without it being known to
> >>> the user.
> >>
> >> strtotime("now"); // gives a 10 digit timestamp which can then be
> >> interpreted by the date();
> >>
> >> http://uk.php.net/manual/en/function.strtotime.php
> >> http://uk.php.net/manual/en/function.date.php
> >
> > I tried this and the date still shows up as 0000-00-00 in the
> > database. Any other thoughts?
>
>
> Echo what the value gives you, and tell us exactly what datatype you field
> in the database is. Probably it doesn't fit, and MySQL resorts to a zero
> value.
>
> You've gotten a link to a good function: date('Y-m-d');
>
> Grtz,
> --
> Rik Wasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация