PHP FAQ and workaround three-up

Source: Internet
Author: User
Tags php code

22: How to get the user's real IP


PHP Code:--------------------------------------------------------------------------------

?
function Iptype1 () {
if (getenv ("Http_client_ip")) {
Return getenv ("Http_client_ip");
}
else {
return "None";
}
}
function Iptype2 () {
if (getenv ("Http_x_forwarded_for")) {
Return getenv ("Http_x_forwarded_for");
}
else {
return "None";
}
}
function Iptype3 () {
if (getenv ("REMOTE_ADDR")) {
Return getenv ("REMOTE_ADDR");
}
else {
return "None";
}
}
function IP () {
$ip 1 = iptype1 ();
$ip 2 = iptype2 ();
$ip 3 = Iptype3 ();
if (Isset ($ip 1) && $ip 1!= "None" && $ip 1!= "Unknown") {
return $IP 1;
}
ElseIf (Isset ($ip 2) && $ip 2!= "None" && $ip 2!= "Unknown") {
return $IP 2;
}
ElseIf (Isset ($ip 3) && $ip 3!= "None" && $ip 3!= "Unknown") {
return $IP 3;
}
else {
return "None";
}
}

Echo IP ();
?>
--------------------------------------------------------------------------------



23: How to read all records in three days from the database

First, there is a datetime field in the table to record the time,
Format is ' 2003-7-15 16:50:00 '

SELECT * from ' xltxlm ' WHERE to_days (now ())-to_days (' Date ') <= 3;


24: How to remotely link the MySQL database


In the Add user's MySQL table there is a host field, modified to "%", or specifies the IP address that allows the connection, so that you can call it remotely.

$link =mysql_connect ("192.168.1.80:3306", "Root", "");


25: Exactly how to use

Click here
Special characters in regular expressions


26: With Apache, the homepage appears garbled


Method One:
Adddefaultcharset Iso-8859-1 changed to adddefaultcharset off

Method Two:
Adddefaultcharset GB2312

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.