PHP WAMPP Accessing the database

Source: Internet
Author: User
Tags openid

Get user Information
Private Function Ulikegetuserinfo ($Wechat, $data)
{
$this->logger ("Reach Ulikegetuserinfo in UlikeFunction.inc.php");
$access _token= $this->get_token ();
$openid = $data [' Fromusername '];
$this->logger ("Fromusername is:" $data [' fromusername ']);
$url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token= $access _token&openid= $openid &LANG=ZH_CN ";
$this->logger ("URL is:". $url);
$jsonInformation = $this->http_curl ($url);
$this->logger ($jsonInformation);
$UserarrInformation =json_decode ($jsonInformation, true);
$this->logger ("Userarrinformation is:". $UserarrInformation);
$this->insertuserinformation ($UserarrInformation, $Wechat);

}
Perform database interpolation
Private Function Insertuserinformation ($User, $Wechat)
{

$this->logger ("reached the database for interpolation processing!");
$this->logger ($User [' OpenID ']);
$link =mysql_connect ("127.0.0.1", "Root", "" ");
if ($link)
{
$this->logger ("database connection succeeded");
}else{
$this->logger ("Database connection failed");
}
mysql_select_db ("Weixin", $link);
$sql = "INSERT into Ulikeuser values (' {$User [" OpenID "]} ', ' {$User [" nickname "]} ', ' {$User [" Sex "]} ', ' {$User [" City "]} ', ' {$User ["Province"]} ', ' {$User ["Headimgurl"]} ', ' ". Time ()." ') ";
$sql = "INSERT into Info values (' Lang ', ' 21 ', ' Boys ')";
$sql 2= "Select sex from Info where name= ' lilang1 '";
mysql_query ($sql, $link);
mysql_query ("Set names ' UTF8 '");//Do not join will appear garbled
$result =mysql_query ($sql, $link);
if ($result)
{$this->logger ("You have executed the database file! ". $result);}
Else
{
$this->logger ("Your data has not been inserted successfully! ");
}
Mysql_close ($link);

}

PHP WAMPP Accessing the database

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.