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; } } Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
sanfordss Posted March 2, 2010 Author Share Posted March 2, 2010 Right on! Thanks! 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.