Hi,
I'm having trouble sending a PHP timestamp command to a MySQL database. I'm sending it as a normal query, but somethings not correct. Can you reccomment a simple tutorial or clarify what I should be doing?
Thanks
Giles
MySQL Timestamp
Moderator: General Moderators
PHP doesn't have a function for making MySQL timestamps. If you're trying to update a MySQL timestamp column with a unix timestamp (as is generated by things like time() and mktime() ) it won't work because it's the wrong format.
If you want to set a timestamp column (or a date column, or a datetime column) to the time that you're carrying out an insert or update query you can set it to NOW() (eg "update table set myTimestampColumn = NOW() where id = 1;" ).
If you want to set a timestamp column (or a date column, or a datetime column) to the time that you're carrying out an insert or update query you can set it to NOW() (eg "update table set myTimestampColumn = NOW() where id = 1;" ).
The MySQL commands FROM_UNIXTIME() and UNIX_TIMESTAMP() are nice for converting between UNIX & MySQL timestamps.
Your question is very unclear. What does 'sending' mean? What made you think something was incorrect?
Your question is very unclear. What does 'sending' mean? What made you think something was incorrect?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
pickle | Please use
thanks for your time
pickle | Please use[/syntax]
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Thanks for the response ... was getting a bit tied up over the form. For anybody who has an interest my working version is :
[syntax="php"]mysql_query(" UPDATE session
SET
session_end = NOW()
WHERE
session_id = '$session_id' ");pickle | Please use[/syntax]
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]