Query question [code = PHP] [/code] & lt ;? Phpinclude (& quot; conn. php & quot;); $ ip =$ _ SERVER ['remote _ ADDR ']; $ result = mysql_query (& quot; select * formipwhereiip = $ ip & quot ;, $ conn) query question
[Code = PHP] [/code]
Include ("conn. php ");
$ Ip = $ _ SERVER ['remote _ ADDR '];
$ Result = mysql_query ("select * form ip where iip = $ ip", $ conn) or die (mysql_error ());
If ($ result ){
Echo "script" alert('failure 'failed when using location.href}'index.html 'script ";
} Else {
Mysql_query ("insert into ip (id, ip) values (null, '$ IP')", $ conn) or die (mysql_error ());
}
?>
Why am I not doing this? Strange, I want to determine whether the client's ip address exists in the ip address table and insert it if it does not exist. if it does exist, the output fails to jump to the home page. but how can I debug it?
------ Solution --------------------
$ Result = mysql_query ("select * form ip where iip = '$ Ip '", $ Conn) or die (mysql_error ());
If ($ result ){
------ Solution --------------------
[Quote = reference:]
[Code = PHP] [/code]
Include ("conn. php ");
$ Ip = $ _ SERVER ['remote _ ADDR '];
$ Result = mysql_query ("select * form ip where iip = $ ip", $ conn) or die (mysql_error ());
If ($ result ){
Echo "script" alert ('failed ......
[/Quote]
Are you sure you want to use iip or not?
$ Result = mysql_query ("select * form ip where ip = '". $ ip. "'", $ conn) or die (mysql_error ());
------ Solution --------------------
$ Result = mysql_query ("select * from ip where iip = '$ IP'", $ conn) or die (mysql_error (); // from is wrong
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