techker Posted December 5, 2011 Share Posted December 5, 2011 hey guys i need to update my traffic table with the log out time.. i record logging and would like to add the log out time.. i tried this..no success date_default_timezone_set('EST'); //Time & Date $date = date ('m/d/y g:i a'); $ip = $_SERVER['REMOTE_ADDR']; $query = "UPDATE `traffic` SET `page` = '$date' WHERE `date` = CURDATE() AND 'ip' = '$ip"; $results = mysql_query( $query ); Quote Link to comment Share on other sites More sharing options...
awjudd Posted December 5, 2011 Share Posted December 5, 2011 You are missing a quote after $ip and you probably don't want the WHERE clause to be based off of CURDATE() since chances are it will never be exactly the same time ... ~awjudd Quote Link to comment Share on other sites More sharing options...
techker Posted December 5, 2011 Author Share Posted December 5, 2011 the current date is good i added the quote but still no update? Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted December 5, 2011 Share Posted December 5, 2011 the mysql function CURDATE() returns the date in the format of YYYY-MM-DD' or YYYYMMDD depending on whether it is used in string or numeric context. you will need to match that format with your date() function in order for the query to grab the correct row. Quote Link to comment Share on other sites More sharing options...
techker Posted December 5, 2011 Author Share Posted December 5, 2011 ok so i set the current date to $date_o = date ('m/d/y'); cause it inserts :$date = date ('m/d/y g:i a'); 12/05/11 9:13 am 70.29.200.146 techker but still nothing?is the AND ok? Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted December 5, 2011 Share Posted December 5, 2011 what value is stored in your date field? Quote Link to comment Share on other sites More sharing options...
techker Posted December 5, 2011 Author Share Posted December 5, 2011 12/05/11 9:13 am with var $date = date ('m/d/y g:i a'); Quote Link to comment Share on other sites More sharing options...
fenway Posted December 5, 2011 Share Posted December 5, 2011 Use SQL-99 date formats. Quote Link to comment Share on other sites More sharing options...
techker Posted December 5, 2011 Author Share Posted December 5, 2011 thx i will google it Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.