Page 1 of 1

I am overriding the value of the variable, looks simple.

Posted: Fri Nov 14, 2008 6:57 pm
by lovelf
Hi, I want to give a value to a variable if a user is coming from certain link that sets the value of $currency to ".php?c=c" but if the user is not coming from that link I want the default value set to nothing, "".

With the code I have I override the value of currency when I try to set a default value.

Code: Select all

<?php
switch($_GET['c']) {
case "c":
$currency = "?c=c";
break;
default:
$currency = "";
break;
}
?>
What should I do to make it work?

Re: I am overriding the value of the variable, looks simple.

Posted: Fri Nov 14, 2008 7:09 pm
by josh
Whats wrong with the code you posted?

Re: I am overriding the value of the variable, looks simple.

Posted: Fri Nov 14, 2008 7:21 pm
by lovelf
When I call $currency it takes the value "" nothing even if I add on the url "?c=c", the second "$currency" on the code sets the value for $currency again, to "" not only by default but even when the switch should set a "?c=c" as a value for $currency.

Re: I am overriding the value of the variable, looks simple.

Posted: Fri Nov 14, 2008 7:28 pm
by lovelf
Nevermind, it does work. :crazy: