I have created a page with a
php script that processes a visitor's ip address and determines its country of origin. When I run the php page in Webmatrix all it does print a portion of the script in the browser window. It happens in FF, IE and Chrome. I have not modified the scrip
at all and it has been around for a few years.
The script code prints starting at the $value part of the statement ,,, foreach($ranges as $key => $value),
This it what shows in the browser window... $value){ if($key<=$code){ if($ranges[$key][0]>=$code){ $two_letter_country_code=$ranges[$key][1];break; } } */ } if ($two_letter_country_code==""){$two_letter_country_code="unkown";} return $two_letter_country_code;
} ?>
Any ideas as to why this is happening and how I might change the code to make it work?
MisterRPH
2 Posts
webmatrix handling of php
Nov 20, 2011 08:56 PM|LINK
I have created a page with a php script that processes a visitor's ip address and determines its country of origin. When I run the php page in Webmatrix all it does print a portion of the script in the browser window. It happens in FF, IE and Chrome. I have not modified the scrip at all and it has been around for a few years.
The script code prints starting at the $value part of the statement ,,, foreach($ranges as $key => $value),
This it what shows in the browser window... $value){ if($key<=$code){ if($ranges[$key][0]>=$code){ $two_letter_country_code=$ranges[$key][1];break; } } */ } if ($two_letter_country_code==""){$two_letter_country_code="unkown";} return $two_letter_country_code; } ?>
Any ideas as to why this is happening and how I might change the code to make it work?
HCamper
8048 Posts
Re: webmatrix handling of php
Nov 20, 2011 11:51 PM|LINK
Hi,
Use IIS Net guide to Improve PHP Error Messages http://learn.iis.net/page.aspx/765/improve-php-error-messages-in-iis-7-and-above/ .
The IP address PHP Script has been around for years and may require some changes.
The problems happen in the all the indicated browsers.
If you copied from the PHP script Web Page then paste into your php script page start looking for HTML Formatting tags
from the Web Page as being a source of problems.
The PHP engine has a built-in set of testing tools you should learn to use them.
From an "Elevated Command Prompt" >php.exe -h displays help.
While still at the Command Prompt >php.exe -l your-php.php script does a syntax check.
Using Command Prompt >php.exe -a your-php.php runs the script interactive mode.
You can get a syntax as part of the Command Prompt >php.exe -s your-php.php helps to find errors.
For changing the code PHP Manual Tips http://www.php.net/tips.php downloads http://www.php.net/download-docs.php .
For more help with PHP look at the PHP net web site suggestions and Faqs http://us3.php.net/FAQ.php
Cheers :)
Martin
Community Member Award 2011
MisterRPH
2 Posts
Re: webmatrix handling of php
Nov 21, 2011 05:28 PM|LINK
Thanks Martin but all I am looking for is quick fix.
I do not have the time or knowledge to work with IIS or learn PHP.
There are no errant HTML tags in the script that cause the problem.
For some reason the PHP engine does not process what appears to be a common use of the PHP foreach construct correctly.
Thanks again for you help.
Richard
HCamper
8048 Posts
Re: webmatrix handling of php
Nov 21, 2011 05:56 PM|LINK
Hi,
I do not see a quick fix.
Before each of the Foreach "include("ip_files/".$numbers[0].".php"); loops the libraries are referenced.
The layout of the folders and includes are part of possible problems.
A guess would be the mis-match for "include("ip_files/" and Ip-files were un-zipped in the IIS Server folder.
Modify php.ini file "include_path=".;c:\php\includes" to have the path to the includes for the "ip_files".
That is all I can suggest.
Martin
Community Member Award 2011
Vegan Fanati...
153 Posts
Re: webmatrix handling of php
Jan 22, 2012 06:27 PM|LINK
This is far from being done.
I have been working on a few projects, including blocking know spammers etc
I am slowly hardening my server from spammers
HCamper
8048 Posts
Re: webmatrix handling of php
Jan 22, 2012 06:31 PM|LINK
Just was a thought :D.
I agree
Community Member Award 2011
Vegan Fanati...
153 Posts
Re: webmatrix handling of php
Jan 22, 2012 06:53 PM|LINK
there are compiled lists of known spammers available
same for ip2ccountry
both are vast databases
HCamper
8048 Posts
Re: webmatrix handling of php
Jan 22, 2012 07:14 PM|LINK
Thanks for the Cautions.
Do not use the Flags PHP code on your server.
Community Member Award 2011