If you are new to domains and looking to buy, sell and learn about domains then you have come to the right place. DNForum is the largest domain name community on the internet and continues to grow every day. There are over 105,000 domainers on DNForum doing everything from buying domains, selling domains, learning about domains and discussing domains. Take a minute and Register.
Register Today on DNForum IT'S FREE!I am going crazy trying to get a simple jump script setup for affiliate links.
I keep getting the following error.
PHP Parse error: parse error, unexpected T_STRING in Line 2
on the following script:
Anyone have any idea what could be wrong here?<?PHP
if ($o == "l1") {$link = "http://www.example.com";} // Default link
if ($o == "l2") {$link = "http://www.anotherexample.com";}
header("Location: $link"); // Jump to the hiddden URL above
exit();
?>
-where is $o defined?
Code:<? switch($o) { case "l2": $redirect="http://www.link2.com"; break; case "l1": $redirect="http://www.link1.com"; break; } header("Location: ".$redirect); ?>
Last edited by Bender; 10-26-2007 at 12:35 PM.
I have my links built like this:
http://www.example.com/jumpscript.php?o=l1
http://www.example.com/jumpscript.php?o=l2
I tried the above script and got the same results. Even with a simple header redirect without variables, I'm getting parse errors. Could there be a server setting, htaccess or php.ini that I'm missing?
Missing ";" at the end of line 2 and 3?
HotWebTools.com
Enamemart.com - Great Names For Sale
CampusHut.com - Students Social Networking
AAV.net AVU.net DGV.net EIE.net FEQ.net FVV.net GOY.net HFB.net MNV.net
OAU.net OEA.net OOD.net OOM.net SUO.net UYO.net VHO.net XHN.net
Code:<? switch($_GET['o']) { case "l2": $redirect="http://www.link2.com"; break; case "l1": $redirect="http://www.link1.com"; break; } header("Location: ".$redirect); ?>
bender - that worked out. thanks so much.
i had a combination of issues - one, was editing in wordpad for some reason and it was throwing in odd formatting.
once i cleared that up, it was clear that the variable wasn't being defined and your new script solved that.
thanks again.
glad to help whenever I can.
Good job Bender.
50 $F donated to your account.
HotWebTools.com
Enamemart.com - Great Names For Sale
CampusHut.com - Students Social Networking
AAV.net AVU.net DGV.net EIE.net FEQ.net FVV.net GOY.net HFB.net MNV.net
OAU.net OEA.net OOD.net OOM.net SUO.net UYO.net VHO.net XHN.net
if you look online the first script i posted seems to be the norm. any specific reason the variable o wasn't being defined in my version?
i'm still a copy and paste php hack, but slowly learning.
the $o variable wasn't defined - you expected to be automatically extracted from the $_GET variables, but this is no longer the case in newer PHP versions(security reasons)
you could use an extract($_GET) but this NOT recommended
You could also do something like...
I do NOT recommend this, though, as someone could run...Code:function pop_vals($associative_array) { foreach ($associative_array as $key=>$val) { eval('$'.$key.' = "'.$val.'";"); } } pop_vals($_REQUEST); // $o should now be defined
YOURURL?o=|1&SOMEREMOTECOMMANDSHERE
Jason
Bookmarks