Jump to content

Archived

This topic is now archived and is closed to further replies.

2wasted

insert timestamp onto database problem

Recommended Posts

You need to convert the time in php to a format MySQL can recognise...

$date = time(); as suggested will not give you a valid date format in MySQL.  Do you just want a current timestamp, if so, use this:

[code]
<?php
$query = "INSERT INTO onlineform (name, Cname, email, query, Pnumber, date) VALUES ('$Name','$Cname','$email','$Query', '$Pnumber', now())";
?>
[/code]

Regards
Huggie

Share this post


Link to post
Share on other sites
$showdate = date('M j, Y  g:i A');
$showdate=strtotime($showdate);

Share this post


Link to post
Share on other sites
[quote author=HuggieBear link=topic=110633.msg447650#msg447650 date=1160090791]
You need to convert the time in php to a format MySQL can recognise...

$date = time(); as suggested will not give you a valid date format in MySQL.  Do you just want a current timestamp, if so, use this:

[code]
<?php
$query = "INSERT INTO onlineform (name, Cname, email, query, Pnumber, date) VALUES ('$name','$Cname','$email','$Query', '$Pnumber', now())";
?>
[/code]

Regards
Huggie
[/quote]
i think you have hit the nail on the head:-)it displays on the page but does not go in to the datamase(MYSQL)

Share this post


Link to post
Share on other sites
OK, so like I said, do you want a current timestamp in the timestamp field?

MySQL's [b]now()[/b] function will do that, see my code above.

Huggie

Share this post


Link to post
Share on other sites
[quote author=HuggieBear link=topic=110633.msg447653#msg447653 date=1160091253]
OK, so like I said, do you want a current timestamp in the timestamp field?

MySQL's [b]now()[/b] function will do that, see my code above.

Huggie
[/quote]
cheers m8,
works!!:-)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.