DarkShadowWing Posted September 8, 2009 Share Posted September 8, 2009 If I wanted to create a table in my database with TIMESTAMP DEFAULT CURRENT_TIMESTAMP, and wanted to check if the same person submitted data before the next day and send an error message depending on if 24 hours has passed on the same person, how would i do that? how could i use this "WHERE timesamp >NOW() +INTERVAL 1 DAY", to detect if its been 24 hours or not since that person's 1st submit? here's the table: <?php $conn = "localhost"; $user = "myuser"; $pass = "mypass"; $dbname = "metaldetect02"; $tbl2 = "users0002"; $con = mysql_connect($conn,$user,$pass); if (!$con) { die('Could not connect to database: "' . $dbname . '" because ' . mysql_error()); } mysql_select_db($dbname, $con); $sql="INSERT INTO $tbl2 (item, firstname, lastname) VALUES ('".$_POST[requireditem]."','".$_POST['requiredfirstname']."','".$_POST['requiredlastname']."')"; echo "Thanks for submitting your item, ".$_POST['requiredfirstname'].", ".$_POST['requiredlastname']."!<br>"; echo "Returning you to the previous page..."; echo "<script>setTimeout('document.location = \"./\";', 2000);</script>"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } mysql_close($con); ?> ANY help is GREATLY appreciated! Link to comment https://forums.phpfreaks.com/topic/173596-need-help-with-timestamp-table-in-sql/ Share on other sites More sharing options...
JonnoTheDev Posted September 8, 2009 Share Posted September 8, 2009 SELECT * FROM table WHERE FROM_UNIXTIME(timestamp) >= DATE_SUB(NOW(),INTERVAL 1 DAY) AND userId='x'; Link to comment https://forums.phpfreaks.com/topic/173596-need-help-with-timestamp-table-in-sql/#findComment-915054 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.