A seriously frustrating (noobie?) PHP problem

Ok, I’ve been looking at this for about an hour now and can find no rhyme or reason why this isn’t working.

I’m from the UK, and am trying to implement a bit of Geo Targetting into my website. I’ve created a function that queries a database fine, so that when I output $country from my laptop, the string “GB” is printed on the screen.

Great.

Now for some reason, when I put in the following code, the string value changes to “US” despite the fact that I’m still accessing exactly the same page from exactly the same location:

<? if($country="US") 
	{
	echo('<link rel="stylesheet" href="../style/us.css" type="text/css" media="screen" />');
	}
	else {
	echo('<link rel="stylesheet" href="../style/default.css" type="text/css" media="screen" />');
	}
	?>

When that simple if() statement is put on to the page, the string GB disappears and the string “US” appears in its place.

I just don’t understand it! How can that be possible from a simple if() statement? No where am I changing the value of the $country variable, so why should it change when I input a simple piece of code??

Any help would be seriously appreciated.

Thanks very much.

Off Topic:

Nope, returns “US”

Try


var_dump($country="US");

:slight_smile:

Try two equal signs in the if statement, you are using an assignment operator and saying:
if (set country to US (returns true I think)), so it processes the first set…

Do this:
if($country== “US”)