欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php微信开发,大神给我看看bug在哪里,找了一下午眼花了

程序员文章站 2024-01-12 15:27:46
...

//怎么第一个if里面老师出问题是哪里语法有问题吗
class Wechat_base_api{
public function get_access_token(){
                   require_once('connect.php');
                   $tim=time();
                   $sql="select * from get_access_token where id=0 and updated_time> $tim";
                  $resu= mysql_query($sql);
                  if($resu){
                      $row=mysql_fetch_assoc($resu);
                      $access_token=$row['content'];
                      return $access_token;
                     
                  }else{
                       $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx5d4c7d2e8ffd5793&secret=4379ef7213c36eae5dc2ab91f9f6aced";                
                       $access_token_Arr =$this->https_request($url);
                      
                    $access_token= $access_token_Arr['access_token'];
                    $newtime=time()+7200;
                     $sqll="update get_access_token set content='{$access_token}' ,updated_time=$newtime where id=0";
                     mysql_query($sqll);
                       return $access_token_Arr['access_token'];
                     
                    
                  }
            }
}

回复内容:


//怎么第一个if里面老师出问题是哪里语法有问题吗
class Wechat_base_api{
public function get_access_token(){
                   require_once('connect.php');
                   $tim=time();
                   $sql="select * from get_access_token where id=0 and updated_time> $tim";
                  $resu= mysql_query($sql);
                  if($resu){
                      $row=mysql_fetch_assoc($resu);
                      $access_token=$row['content'];
                      return $access_token;
                     
                  }else{
                       $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx5d4c7d2e8ffd5793&secret=4379ef7213c36eae5dc2ab91f9f6aced";                
                       $access_token_Arr =$this->https_request($url);
                      
                    $access_token= $access_token_Arr['access_token'];
                    $newtime=time()+7200;
                     $sqll="update get_access_token set content='{$access_token}' ,updated_time=$newtime where id=0";
                     mysql_query($sqll);
                       return $access_token_Arr['access_token'];
                     
                    
                  }
            }
}
相关标签: php