Solved

MySQL Timestamp Now() and PHP

Posted on 2006-06-12
2
1,110 Views
Last Modified: 2013-12-12
I have added a new timestamp field to my table. I have added the field name to the insert command in the form yet when I get the results back I just get 00000000000000. I image that I need to add NOW() to this, but I cant figure out how.

Here is the insert section:

mysql_select_db('test');
$query = "insert into support values
('".$id."', '".$time."', '".$number."', '".$domainname."', '".$fpon."', '".$comments."', '".$name."', '".$email."')";


Any suggestions?

Thanks,

Bruce
0
Comment
Question by:safepointmedia
2 Comments
 
LVL 33

Accepted Solution

by:
snoyes_jw earned 500 total points
ID: 16887977
Assuming that the user is not supposed to provide the timestamp, I imagine you want to replace $time with NOW(). So:

$query = "insert into support values ('$id', NOW(), '$number', '$domainname', '$fpon', '$comments', '$name', '$email')";
0
 
LVL 5

Expert Comment

by:aminerd
ID: 16888068
Otherwise, $time probably contains a UNIX timestamp, which isn't the same as a MySQL timestamp:

$query = "insert into support values ('".$id."', '".date('Y-m-d H:i:s', $time)."', '".$number."', '".$domainname."', '".$fpon."', '".$comments."', '".$name."', '".$email."')";
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now