Hi this is my first post here, I am using:
$server_time = gettimeofday(True);
to retrieve time to store in phpMyAdmin. at the same time I want to store it in to a non changeable value variable., making sure the time stored in phpMyAdmin is exactly he same as the non changeable value variable, how do I do so ?
Next is I need to store the logout time in to the same id line in phpMyadmin where I first stored the $server_time = gettimeofday(True);
. But how do I know what id it was stored in ? when there are literally many people logging in ?
Digi
I have run into this myself. Paul is right. You should use the NOW() if you don't want all items being entered to have the same stamp (like a batch number). I use two solutions. If I want to ensure that the wrong user doesn't get someone elses ID then I do Example 2. But example one is my first option instead of using PHP's built in function.
<?php
$sql_in = "INSERT INTO `table` ( `id` , `stamp` , `user` )
VALUES (
NULL , NOW( ) , '".addslashes($name)."' )";
$result_in = @mysql_query($sql_in, $GLOBALS['database']) or die(mysql_error());
$sql_in = "SELECT LAST_INSERT_ID() as 'insertedId' FROM `table`";
$result_in = @mysql_query($sql_in, $GLOBALS['mainFrame']) or die(mysql_error());
$row_InsertedId = mysql_fetch_array($result_in);
$saveid = $row_InsertedId[insertedId];
?>
Creating a md5 unique so you can call it back to find the Unique ID auto generated.
<?php
// uniquesessionid
$uniqueKey = md5(uniqid(rand(), true));
$sql_in = "INSERT INTO `table` ( `id` , `stamp` , `user`, `tempkey` )
VALUES (
NULL , NOW( ) , '".addslashes($name)."', '$uniqueKey' )";
$result_in = @mysql_query($sql_in, $GLOBALS['database']) or die(mysql_error());
// ID
$sql_in = "SELECT `id` FROM `table`" WHERE `tempKey` = '$uniqueKey' LIMIT 1;
$result_in = @mysql_query($sql_in, $GLOBALS['mainFrame']) or die(mysql_error());
$row_InsertedId = mysql_fetch_array($result_in);
$saveid = $row_InsertedId[insertedId];
?>
Hope this helps.