runnerjp Posted February 14, 2010 Share Posted February 14, 2010 Im trying to set up a script so users can see if any new posts have been in the forum since their last visit to that forum. The code is below but it always seems to show no new posts even if there is :S General has 1266143084 and last post has 1266143616 ... Where am i going wrong>>> $getthreads_result = mysql_query("Select * from forumtutorial_posts where parentid='0' and forum = 'general' ORDER BY lastrepliedto DESC ") or die("Could not get threads"); $getthreads = mysql_fetch_array($getthreads_result); $getlastpost = mysql_fetch_assoc(mysql_query("SELECT * FROM users WHERE Username = '$username' ")); echo "<img src=\"http://www.runningprofiles.com/images/postforum.", (($getlastpost['General'] <= $getthreads['lastrepliedto']) ? "gif" : "jpg"), "\" alt=\"My\" />"; Link to comment https://forums.phpfreaks.com/topic/192024-comparing-two-timedate-fields/ Share on other sites More sharing options...
jl5501 Posted February 14, 2010 Share Posted February 14, 2010 A quick look at your code suggests that this line echo "<img src=\"http://www.runningprofiles.com/images/postforum.", (($getlastpost['General'] <= $getthreads['lastrepliedto']) ? "gif" : "jpg"), "\" alt=\"My\" />"; should be echo "<img src=\"http://www.runningprofiles.com/images/postforum.". (($getlastpost['General'] <= $getthreads['lastrepliedto']) ? "gif" : "jpg"). "\" alt=\"My\" />"; but I would printf such a line like this printf("<img src=\"http://www.runningprofiles.com/images/postforum.%s\" alt=\"My\" />",($getlastpost['General'] <= $getthreads['lastrepliedto']) ? "gif" : "jpg"); Link to comment https://forums.phpfreaks.com/topic/192024-comparing-two-timedate-fields/#findComment-1012057 Share on other sites More sharing options...
runnerjp Posted February 14, 2010 Author Share Posted February 14, 2010 Ok for some reason it seems to work if the post was more then an hour difference rather then seconds... why is this? Link to comment https://forums.phpfreaks.com/topic/192024-comparing-two-timedate-fields/#findComment-1012122 Share on other sites More sharing options...
jl5501 Posted February 14, 2010 Share Posted February 14, 2010 how are you generating your timestamps? maybe they are only created to the nearest hour Link to comment https://forums.phpfreaks.com/topic/192024-comparing-two-timedate-fields/#findComment-1012127 Share on other sites More sharing options...
runnerjp Posted February 14, 2010 Author Share Posted February 14, 2010 $thedate=date("U"); //get unix timestamp Link to comment https://forums.phpfreaks.com/topic/192024-comparing-two-timedate-fields/#findComment-1012145 Share on other sites More sharing options...
jl5501 Posted February 14, 2010 Share Posted February 14, 2010 well that should certainly return a unix timestamp in seconds Link to comment https://forums.phpfreaks.com/topic/192024-comparing-two-timedate-fields/#findComment-1012146 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.