Solved

MySQL Timestamp Now() and PHP

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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.

623 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