Jump to content


Photo

A Timestamp Wtf


  • Please log in to reply
3 replies to this topic

#1 dark dude

dark dude
  • Members
  • PipPipPip
  • Advanced Member
  • 53 posts

Posted 26 June 2006 - 04:17 PM

Ok, I've been in need of timestamps, and all was going well, but for some reason, it doesnt like to put the timestamp onto my database...

Look at my script:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?
session_start();
?>

<body bgcolor='#000033' text='#CCFFFF'>

<?

$Username = $_SESSION['Username'];

$Reciever=$_POST['Reciever'];
$Type=$_POST['Type'];
$Subject=$_POST['Subject'];
$MessageBody=$_POST['MessageBody'];

include("dbinfo.inc.php");

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query = "SELECT * FROM Users WHERE Username='$Reciever'";
$result = mysql_query($query) or die(mysql_error());

$Username3=mysql_result($result,$i,"Username");

$quotes_array = file('gamemods.txt');

if($Username3==''){
echo "The Reciepant does not exist!";
}
else {

if($Type=="Report"){
$quote = $quotes_array[rand(0, count($quotes_array) - 1)];
$quote = trim($quote);

$query = "INSERT INTO Messages VALUES ('',UNIX_TIMESTAMP(),'$Username','$quote','$Subject','$MessageBody','$Type')";
mysql_query($query);
} else {
$query = "INSERT INTO Messages VALUES ('',UNIX_TIMESTAMP(),'$Username','$Reciever','$Subject','$MessageBody','$Type')";
mysql_query($query);
}
mysql_close();

?>

Your <?
if($Type=="Report"){
echo "Report ";
}
elseif($Type=="PM"){
echo "Private Message ";
}
elseif($Type=="SPM"){
echo "Anonymous Private Message (This type of Private Message is not shown in Mod Message logs) ";
}
else{
echo "$Type ";
}
?>
has been sent!<br><br>
Please note that Reports are automatically sent to Game Moderators to prevent confusion.

<?
}
[/quote]

Everything seems to be ok, but look what happens when I go through the script:

[a href=\"http://img327.imageshack.us/img327/1303/tsprob1nf.png\" target=\"_blank\"]http://img327.imageshack.us/img327/1303/tsprob1nf.png[/a]

Incase you needed to know, here's the databases settings that it goes to:
[a href=\"http://img288.imageshack.us/img288/7987/fissue5nv.png\" target=\"_blank\"]http://img288.imageshack.us/img288/7987/fissue5nv.png[/a]

Any help that works will be much appreciated [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 26 June 2006 - 04:20 PM

I think you need to the place date in the perenthesis like so:
UNIX_TIMESTAMP(NOW())

#3 fractil

fractil
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 26 June 2006 - 04:32 PM

I believe you can just use NOW().

See: [a href=\"http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html\" target=\"_blank\"]http://dev.mysql.com/doc/refman/5.0/en/dat...-functions.html[/a]

Cheers!
"One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs"

#4 dark dude

dark dude
  • Members
  • PipPipPip
  • Advanced Member
  • 53 posts

Posted 26 June 2006 - 04:58 PM

Wow! Thanks very much! I've been to 4 different forums/help teams, and they all havent helped, but you have ^_^




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users