sanfordss Posted March 2, 2010 Share Posted March 2, 2010 I have this script that does not work and I don't know why. I'm not very good at php, so I'm hoping the PHP Freaks can give a hand. Here's how it's supposed to work- The status of a request is set to hold when a proposal is accepted. the tech has 24 hours to confirm the acceptance. If 24 hours goes by, that request should go back to Open. Sounds simple, but it just won't work. Here's what I have. Any insight would be appreciated... //check whether or not a request on hold should be reopened function f_check_reopen_request($connection, $reqid){ $query = "select * from `bidding` where `b_reqid`='$reqid' and `acc_rej`='accepted'"; $result = $connection->query($query); if($result->num_rows > 0){ $bid = f_create_result_array($result); $now = mktime(); $dates = explode(" ", $bid[0]['acc_rej_timestamp']); $times = explode(":", $dates[1]); $my_dates = explode("-", $dates[0]); $accept_time = mktime($times[0],$times[1],$times[2],$my_dates[1],$my_dates[2],$my_dates[0]); //$difference = floor(($now - $accept_time) / (24 * 60 * 60)); $difference = floor(($now - $accept_time)/(600)); if($difference > 1){ //set the request and bids back to open f_set_request_status($connection, $reqid, "open"); $bids = f_get_request_bids($connection, $reqid); foreach($bids as $bid){ f_set_bid_status($connection, "open", $bid['bid_id']); } return true; }else{ return false; } }else{ return false; } } Link to comment https://forums.phpfreaks.com/topic/193939-set-the-status-to-open-after-24-hours/ Share on other sites More sharing options...
schilly Posted March 2, 2010 Share Posted March 2, 2010 Just do everything in your query. $sql = "UPDATE bidding SET status = 'OPEN' WHERE acc_rej = 'accepted' AND acc_rej_timestamp <= DATE_SUB(NOW() INTERVAL 24 HOUR)"; that should work. Link to comment https://forums.phpfreaks.com/topic/193939-set-the-status-to-open-after-24-hours/#findComment-1020626 Share on other sites More sharing options...
sanfordss Posted March 2, 2010 Author Share Posted March 2, 2010 Right on! Thanks! Link to comment https://forums.phpfreaks.com/topic/193939-set-the-status-to-open-after-24-hours/#findComment-1020631 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.