I have a dedicated .php redirect I use for every affiliate offer on my sites. On this particular site/offer, there is a USA and Canada offer, so Im redirecting myself using the Geo-IP script. Like so:
The problem starts when I see that another network has the same offer for double the payout, and it doesn't require redirecting to the appropriate country. So I'm trying to this:
What's weird is it seems to work, but only about 80% of the time. 20% of the time it gave me an error on the else line
It didn't like a curly brace. Does the code above look correct? Or is it possible that my browser cached a bunk file with an error when I was first coding it out and was using that instead?
Code:
<?php
require_once("geoplugin.class.php");
$geoplugin = new geoPlugin();
$geoplugin->locate();
$country_code = $geoplugin->countryCode;
switch($country_code) {
case 'US':
header("Location: http://afflink1.com/usa.php");
exit;
case 'CA':
header("Location: http://afflink2.com/ca.php");
exit;
default: // exceptions
header("Location: http://blah.com");
exit;
}
?>
The problem starts when I see that another network has the same offer for double the payout, and it doesn't require redirecting to the appropriate country. So I'm trying to this:
Code:
<?php
$url = rand(0,1);
if($url == 0){
header("Location: http://splittestingthisin.com");
} else {
require_once("geoplugin.class.php");
$geoplugin = new geoPlugin();
$geoplugin->locate();
$country_code = $geoplugin->countryCode;
switch($country_code) {
case 'US':
header("Location: http://afflink1.com/usa.php");
exit;
case 'CA':
header("Location: http://afflink2.com/ca.php");
exit;
default: // exceptions
header("Location: http://blah.com");
exit;
}
}
?>
What's weird is it seems to work, but only about 80% of the time. 20% of the time it gave me an error on the else line
Code:
if($url == 0){
header("Location: http://splittestingthisin.com");
} else { //this line the error occurs.
It didn't like a curly brace. Does the code above look correct? Or is it possible that my browser cached a bunk file with an error when I was first coding it out and was using that instead?