Include() statement - injecting value into a variable

Hi,
I’m trying to form a simple geo-targeting call, using Using the Database - IP Address Lookup - Community Geotarget IP Addresses Project , in which I insert my site visitor’s country into a URL, and act accordingly.

Basically, if you click on http://api.hostip.info/country.php it returns your 2-letter country code, so I would like to do something like:

$country=include(http://api.hostip.info/country.php);

But of course, this syntax actually returns $country = 1 (success) or 0 (failure).
How do I get it to return $country = US (or UK, or SE etc.)?

Thanks!
Andy

Use file_get_contents instead of include.

If that doesn’t work (it should, or your include would have failed), you’ll have to do something like cURL the page to get the data into a variable.

Ps - this will only return the SERVERs country of origin. If you want the clients, you’ll need to feed that page some data somehow.

That was quick! Thanks!
No problem injecting the client IP once I get it. something like

file_get_contents(http://api.hostip.info/country.php?ip=VISITORS_IP)

Will try that 1st thing tomorrow and post here whether it worked.
Thanks.