Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MySQL Timestamp Now() and PHP

Posted on 2006-06-12
2
Medium Priority
?
1,117 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
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…
The viewer will learn how to count occurrences of each item in an array.
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.

721 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