Entering current date and time into MySQL database using PHP.
Entering current date and time into MySQL database using PHP.
am 06.08.2006 20:06:30 von mpar612
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.
My table in MySQL is setup with add_date as date not null.
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.
Does anyone have any thoughts on how this is done?
Thanks!
Re: Entering current date and time into MySQL database using PHP.
am 06.08.2006 20:36:57 von Shion
mpar612@gmail.com wrote:
First, PLEASE don't multipost, if you have to ask the same question at more
than one newsgroup then make a crosspost, don't select more than a handful
relevant newsgroups,
> 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.
>
> My table in MySQL is setup with add_date as date not null.
>
> 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']));
What data type have for your add_date column?
I think you may need to use unix_timestamp() instead.
//Aho
Re: Entering current date and time into MySQL database using PHP.
am 06.08.2006 20:49:26 von IchBin
mpar612@gmail.com wrote:
> 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.
>
> My table in MySQL is setup with add_date as date not null.
>
> 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.
>
> Does anyone have any thoughts on how this is done?
>
> Thanks!
>
You can define your DB 'add_date' column as a timestamp with the
following format:
add_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP
This way you could eliminate any reference to 'add_date' in you code but
have it automatically inserted on a insert or update to that DB row.
Look at this link
http://dev.mysql.com/doc/refman/5.0/en/timestamp-4-1.html
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
____________________________________________________________ ______________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Re: Entering current date and time into MySQL database using PHP.
am 06.08.2006 20:57:03 von mpar612
IchBin wrote:
> mpar612@gmail.com wrote:
> > 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.
> >
> > My table in MySQL is setup with add_date as date not null.
> >
> > 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.
> >
> > Does anyone have any thoughts on how this is done?
> >
> > Thanks!
> >
>
> You can define your DB 'add_date' column as a timestamp with the
> following format:
>
> add_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
> ON UPDATE CURRENT_TIMESTAMP
>
> This way you could eliminate any reference to 'add_date' in you code but
> have it automatically inserted on a insert or update to that DB row.
>
> Look at this link
> http://dev.mysql.com/doc/refman/5.0/en/timestamp-4-1.html
>
> Thanks in Advance...
> IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
> ____________________________________________________________ ______________
>
> 'If there is one, Knowledge is the "Fountain of Youth"'
> -William E. Taylor, Regular Guy (1952-)
Thanks! This works great! Is there an easy way to retrieve this date
and reformat it using PHP?
Thanks again!
Re: Entering current date and time into MySQL database using PHP.
am 06.08.2006 21:14:32 von IchBin
mpar612@gmail.com wrote:
> IchBin wrote:
>> mpar612@gmail.com wrote:
>>> 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.
>>>
>>> My table in MySQL is setup with add_date as date not null.
>>>
>>> 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.
>>>
>>> Does anyone have any thoughts on how this is done?
>>>
>>> Thanks!
>>>
>> You can define your DB 'add_date' column as a timestamp with the
>> following format:
>>
>> add_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
>> ON UPDATE CURRENT_TIMESTAMP
>>
>> This way you could eliminate any reference to 'add_date' in you code but
>> have it automatically inserted on a insert or update to that DB row.
>>
>> Look at this link
>> http://dev.mysql.com/doc/refman/5.0/en/timestamp-4-1.html
>>
>> Thanks in Advance...
>> IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
>> ____________________________________________________________ ______________
>>
>> 'If there is one, Knowledge is the "Fountain of Youth"'
>> -William E. Taylor, Regular Guy (1952-)
>
> Thanks! This works great! Is there an easy way to retrieve this date
> and reformat it using PHP?
> Thanks again!
>
Since you multi-posted and not crossed posted another person answered
you question in another newsgroup.
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
____________________________________________________________ ______________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Re: Entering current date and time into MySQL database using PHP.
am 07.08.2006 14:56:14 von mpar612
IchBin wrote:
> mpar612@gmail.com wrote:
> > IchBin wrote:
> >> mpar612@gmail.com wrote:
> >>> 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.
> >>>
> >>> My table in MySQL is setup with add_date as date not null.
> >>>
> >>> 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.
> >>>
> >>> Does anyone have any thoughts on how this is done?
> >>>
> >>> Thanks!
> >>>
> >> You can define your DB 'add_date' column as a timestamp with the
> >> following format:
> >>
> >> add_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
> >> ON UPDATE CURRENT_TIMESTAMP
> >>
> >> This way you could eliminate any reference to 'add_date' in you code but
> >> have it automatically inserted on a insert or update to that DB row.
> >>
> >> Look at this link
> >> http://dev.mysql.com/doc/refman/5.0/en/timestamp-4-1.html
> >>
> >> Thanks in Advance...
> >> IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
> >> ____________________________________________________________ ______________
> >>
> >> 'If there is one, Knowledge is the "Fountain of Youth"'
> >> -William E. Taylor, Regular Guy (1952-)
> >
> > Thanks! This works great! Is there an easy way to retrieve this date
> > and reformat it using PHP?
> > Thanks again!
> >
>
> Since you multi-posted and not crossed posted another person answered
> you question in another newsgroup.
>
> Thanks in Advance...
> IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
> ____________________________________________________________ ______________
>
> 'If there is one, Knowledge is the "Fountain of Youth"'
> -William E. Taylor, Regular Guy (1952-)
Hi everyone,
First, thank you very much for your help. Second, I apologize for not
using proper Google netiquette. I am new to forums and was not aware
of how things work.
Thanks again for everyone's help and I will make all of my posts proper
from now on.
Re: Entering current date and time into MySQL database using PHP.
am 07.08.2006 14:56:14 von mpar612
IchBin wrote:
> mpar612@gmail.com wrote:
> > IchBin wrote:
> >> mpar612@gmail.com wrote:
> >>> 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.
> >>>
> >>> My table in MySQL is setup with add_date as date not null.
> >>>
> >>> 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.
> >>>
> >>> Does anyone have any thoughts on how this is done?
> >>>
> >>> Thanks!
> >>>
> >> You can define your DB 'add_date' column as a timestamp with the
> >> following format:
> >>
> >> add_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
> >> ON UPDATE CURRENT_TIMESTAMP
> >>
> >> This way you could eliminate any reference to 'add_date' in you code but
> >> have it automatically inserted on a insert or update to that DB row.
> >>
> >> Look at this link
> >> http://dev.mysql.com/doc/refman/5.0/en/timestamp-4-1.html
> >>
> >> Thanks in Advance...
> >> IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
> >> ____________________________________________________________ ______________
> >>
> >> 'If there is one, Knowledge is the "Fountain of Youth"'
> >> -William E. Taylor, Regular Guy (1952-)
> >
> > Thanks! This works great! Is there an easy way to retrieve this date
> > and reformat it using PHP?
> > Thanks again!
> >
>
> Since you multi-posted and not crossed posted another person answered
> you question in another newsgroup.
>
> Thanks in Advance...
> IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
> ____________________________________________________________ ______________
>
> 'If there is one, Knowledge is the "Fountain of Youth"'
> -William E. Taylor, Regular Guy (1952-)
Hi everyone,
First, thank you very much for your help. Second, I apologize for not
using proper Google netiquette. I am new to forums and was not aware
of how things work.
Thanks again for everyone's help and I will make all of my posts proper
from now on.
Re: Entering current date and time into MySQL database using PHP.
am 07.08.2006 15:04:30 von Rik
mpar612@gmail.com wrote:
> Hi everyone,
>
> First, thank you very much for your help. Second, I apologize for not
> using proper Google netiquette. I am new to forums and was not aware
> of how things work.
>
> Thanks again for everyone's help and I will make all of my posts
> proper
> from now on.
Well, thank you very much.
2 points though:
1. This is not a forum, this is usenet. Google only has made a webinterface
to it. I personally think using a newsreader is a lot less cumbersome then
some webinterface.
2. It's not Google netiquette, it existed way before Google.
Thanks for taking the time to learn the netiquette,
--
Rik Wasmus
Re: Entering current date and time into MySQL database using PHP.
am 07.08.2006 15:04:30 von Rik
mpar612@gmail.com wrote:
> Hi everyone,
>
> First, thank you very much for your help. Second, I apologize for not
> using proper Google netiquette. I am new to forums and was not aware
> of how things work.
>
> Thanks again for everyone's help and I will make all of my posts
> proper
> from now on.
Well, thank you very much.
2 points though:
1. This is not a forum, this is usenet. Google only has made a webinterface
to it. I personally think using a newsreader is a lot less cumbersome then
some webinterface.
2. It's not Google netiquette, it existed way before Google.
Thanks for taking the time to learn the netiquette,
--
Rik Wasmus
Re: Entering current date and time into MySQL database using PHP.
am 07.08.2006 22:21:30 von IchBin
Rik wrote:
> mpar612@gmail.com wrote:
>> Hi everyone,
>>
>> First, thank you very much for your help. Second, I apologize for not
>> using proper Google netiquette. I am new to forums and was not aware
>> of how things work.
>>
>> Thanks again for everyone's help and I will make all of my posts
>> proper
>> from now on.
>
> Well, thank you very much.
>
> 2 points though:
> 1. This is not a forum, this is usenet. Google only has made a webinterface
> to it. I personally think using a newsreader is a lot less cumbersome then
> some webinterface.
> 2. It's not Google netiquette, it existed way before Google.
>
Just for the hell-of-it:
What are Usenet newsgroups (Not Google's own web interface interface to it)?
They have been described in many ways but simply -- are discussion
groups on the Internet organized by subject matter. MP3, hobbies,
sports, (and yes, even pornography) are some of the subjects of many
newsgroups. Users in a newsgroup participate in discussions by posting
messages for others to read, and responding to the messages posted by
others. Although not the original intention of Usenet, posts can also
consist of software, music, and pictures freely available for
downloading. Currently there are over 100,000 newsgroup available and
new groups are added every day.
When did Usenet begin?
Usenet began in 1979, shortly after the release of Version 7 Unix with
UUCP (Unix to Unix CoPy: protocol used for the store-and-forward
exchange of Usenet News and other files). Duke University graduate
students Tom Truscott and Jim Ellis thought of linking computers
together to exchange information with the Unix community. Steve
Bellovin, a graduate student at the University of North Carolina, put
together the first version of the news software using shell scripts and
installed it on the first two sites: "unc" and "duke." At the beginning
of 1980 the network consisted of those two sites and "phs" (another
machine at Duke), and was displayed at the January Usenix conference.
Steve Bellovin later developed the scripts into C programs, but they
were never released beyond "unc" and "duke." Steve Daniel did another
implementation in C for public distribution as well. Tom Truscott made
further modifications, and this became the "A" news release.
> Thanks for taking the time to learn the netiquette,
http://www.cs.indiana.edu/docproject/zen/zen-1.0_6.html
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
____________________________________________________________ ______________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Re: Entering current date and time into MySQL database using PHP.
am 07.08.2006 22:21:30 von IchBin
Rik wrote:
> mpar612@gmail.com wrote:
>> Hi everyone,
>>
>> First, thank you very much for your help. Second, I apologize for not
>> using proper Google netiquette. I am new to forums and was not aware
>> of how things work.
>>
>> Thanks again for everyone's help and I will make all of my posts
>> proper
>> from now on.
>
> Well, thank you very much.
>
> 2 points though:
> 1. This is not a forum, this is usenet. Google only has made a webinterface
> to it. I personally think using a newsreader is a lot less cumbersome then
> some webinterface.
> 2. It's not Google netiquette, it existed way before Google.
>
Just for the hell-of-it:
What are Usenet newsgroups (Not Google's own web interface interface to it)?
They have been described in many ways but simply -- are discussion
groups on the Internet organized by subject matter. MP3, hobbies,
sports, (and yes, even pornography) are some of the subjects of many
newsgroups. Users in a newsgroup participate in discussions by posting
messages for others to read, and responding to the messages posted by
others. Although not the original intention of Usenet, posts can also
consist of software, music, and pictures freely available for
downloading. Currently there are over 100,000 newsgroup available and
new groups are added every day.
When did Usenet begin?
Usenet began in 1979, shortly after the release of Version 7 Unix with
UUCP (Unix to Unix CoPy: protocol used for the store-and-forward
exchange of Usenet News and other files). Duke University graduate
students Tom Truscott and Jim Ellis thought of linking computers
together to exchange information with the Unix community. Steve
Bellovin, a graduate student at the University of North Carolina, put
together the first version of the news software using shell scripts and
installed it on the first two sites: "unc" and "duke." At the beginning
of 1980 the network consisted of those two sites and "phs" (another
machine at Duke), and was displayed at the January Usenix conference.
Steve Bellovin later developed the scripts into C programs, but they
were never released beyond "unc" and "duke." Steve Daniel did another
implementation in C for public distribution as well. Tom Truscott made
further modifications, and this became the "A" news release.
> Thanks for taking the time to learn the netiquette,
http://www.cs.indiana.edu/docproject/zen/zen-1.0_6.html
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
____________________________________________________________ ______________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)