Hi all I have a big problem how to figure out why this will not work: I have a table to record all links that is clicked with a timestamp, but unfortantly I cant find the right code to use it: My code is: <?php error_reporting(E_ALL ^ E_NOTICE); define('IN_SCRIPT',1); /* Get settings from the settings.php file */ require 'settings.php'; /* Get database connection from the database.php file */ require 'database.php'; /* Start user session or output an error */ session_name('CCOUNT'); if (!session_start()) { error('Cannot start a new PHP session. Please contact server administrator or webmaster!'); } function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; } mysql_select_db("awc24h_links", $con); $user_id = $settings['user_id']; $result = mysql_query("Select * FROM Log where user_id='".$user_id."' AND url='".curPageURL()."' AND last_visit<'NOW() - INTERVAL 1 DAY'"); if (mysql_num_rows($result)<1) { // $result = mysql_query("SELECT * FROM Click order by RANDOM() LIMIT 1"); echo '24 hours have passed'; } else { // header("Location: show.php"); echo 'under 24 hours since last click <br><br>'; echo curPageURL(); echo '<br>'; echo $user_id; echo NOW(); } ?> Code (markup): Hope some one can help me figure this out
You've got some bad syntax here: $result = mysql_query("Select * FROM Log where user_id='".$user_id."' AND url='".curPageURL()."' AND last_visit<'NOW() - INTERVAL 1 DAY'"); PHP: Try: $result = mysql_query("SELECT * FROM Log WHERE user_id = $user_id AND url = '".curPageURL()."' AND last_visit >= (DATE_SUB(CURDATE(), INTERVAL 1 DAY))"); PHP:
It keep saying under 24 hours since last click: under 24 hours since last click: http://www.awc24h.com/click/installation/test.php installation
No still not working Timestamp is now :2012-10-17 02:41:28, means yester day today is 2012 -10 -18 should say over 24 hours since last click