php微信开发,求大牛看看那里问题

WBOY
Release: 2016-06-06 20:22:46
Original
1120 people have browsed it

<code>第一个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'];
                     
                    
                  }
            }
}</code>
Copy after login
Copy after login

回复内容:

<code>第一个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'];
                     
                    
                  }
            }
}</code>
Copy after login
Copy after login

面向对象的就没错,面向对象的就错了

看不懂你要问什么

看下$resu是什么?
话说你的mysql_query就能这么直接用了?

既然都面向对象了还手动引用数据库

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!