Jump to content

Date() and Mysql


Drezard

Recommended Posts

Hello, Whenever I store an output from Date(YmdGi); into my mysql database. It always comes up as the same number...

 

E.G: My database looks like this

 

Timestamp        |  Username

 

2147483647          John

2147483647          Jack

2147483647          Peter

 

Here is my script:

 


// $username = Form data

$timestamp = date(YmdGi);

echo "$timestamp";

$result ("INSERT INTO users (timestamp, username) VALUES ('$timestamp', '$username')");

 

When I run this script it outputs something like 200703251056 but then in the database its always that same number....

 

What am i doing wrong?

 

- Cheers, Daniel

Link to comment
https://forums.phpfreaks.com/topic/44182-date-and-mysql/
Share on other sites

For a users online script useing the UNIX_TIMESTAMP();

put this in the page where it logs the time of the user:

mysql_query("UPDATE `tablename` SET `last_online`=UNIX_TIMESTAMP() WHERE `mid`='$id'");

 

The users online script itself:

$names = mysql_query("SELECT `name` FROM `tablename` WHERE `last_online`=UNIX_TIMESTAMP()-300"); //simple calculation 60*5 = 300
echo $names;

Link to comment
https://forums.phpfreaks.com/topic/44182-date-and-mysql/#findComment-214552
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.