Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MySQL Timestamp Now() and PHP

Posted on 2006-06-12
2
Medium Priority
?
1,122 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 2000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

783 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