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 ); Link to comment https://forums.phpfreaks.com/topic/252508-update-query-with-and/ 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 Link to comment https://forums.phpfreaks.com/topic/252508-update-query-with-and/#findComment-1294602 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? Link to comment https://forums.phpfreaks.com/topic/252508-update-query-with-and/#findComment-1294603 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. Link to comment https://forums.phpfreaks.com/topic/252508-update-query-with-and/#findComment-1294604 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? Link to comment https://forums.phpfreaks.com/topic/252508-update-query-with-and/#findComment-1294606 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? Link to comment https://forums.phpfreaks.com/topic/252508-update-query-with-and/#findComment-1294610 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'); Link to comment https://forums.phpfreaks.com/topic/252508-update-query-with-and/#findComment-1294656 Share on other sites More sharing options...
fenway Posted December 5, 2011 Share Posted December 5, 2011 Use SQL-99 date formats. Link to comment https://forums.phpfreaks.com/topic/252508-update-query-with-and/#findComment-1294674 Share on other sites More sharing options...
techker Posted December 5, 2011 Author Share Posted December 5, 2011 thx i will google it Link to comment https://forums.phpfreaks.com/topic/252508-update-query-with-and/#findComment-1294680 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.