Solved

MySQL Timestamp Now() and PHP

Posted on 2006-06-12
2
1,109 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

757 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

21 Experts available now in Live!

Get 1:1 Help Now