 | Welcome to Dnforum.com
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast and simple so please, join our community today!
If you have any problems with the registration process or your account login, please contact us. |  |
10-26-2007, 12:14 PM
|
#1 (permalink)
| | DNF Member
Last Online: Yesterday 10:28 PM Join Date: Jul 2007
Posts: 401
DNF$: 1,113 Location: United States
Country: | Jump Script Parse Error 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: Quote:
<?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();
?>
| Anyone have any idea what could be wrong here? |
| |
10-26-2007, 12:32 PM
|
#2 (permalink)
| | www.LOL.biz
Name: Daniel Last Online: 07-07-2008 10:31 PM Join Date: Apr 2004
Posts: 1,783
DNF$: 5,162 Location: .ro
Country: | -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.
|
| |
10-26-2007, 01:13 PM
|
#3 (permalink)
| | DNF Member
Last Online: Yesterday 10:28 PM Join Date: Jul 2007
Posts: 401
DNF$: 1,113 Location: United States
Country: | 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? |
| |
10-26-2007, 01:23 PM
|
#4 (permalink)
| | Exclusive Senior Newbie
Last Online: Yesterday 11:28 PM Join Date: Apr 2004
Posts: 8,040
DNF$: 5,244 Location: On Earth
Country: | Missing ";" at the end of line 2 and 3? |
| |
10-26-2007, 01:59 PM
|
#5 (permalink)
| | www.LOL.biz
Name: Daniel Last Online: 07-07-2008 10:31 PM Join Date: Apr 2004
Posts: 1,783
DNF$: 5,162 Location: .ro
Country: | Code: <?
switch($_GET['o'])
{
case "l2":
$redirect="http://www.link2.com";
break;
case "l1":
$redirect="http://www.link1.com";
break;
}
header("Location: ".$redirect);
?> |
| |
10-26-2007, 04:05 PM
|
#6 (permalink)
| | DNF Member
Last Online: Yesterday 10:28 PM Join Date: Jul 2007
Posts: 401
DNF$: 1,113 Location: United States
Country: | 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. |
| |
10-26-2007, 04:09 PM
|
#7 (permalink)
| | www.LOL.biz
Name: Daniel Last Online: 07-07-2008 10:31 PM Join Date: Apr 2004
Posts: 1,783
DNF$: 5,162 Location: .ro
Country: | glad to help whenever I can. |
| |
10-26-2007, 04:11 PM
|
#8 (permalink)
| | Exclusive Senior Newbie
Last Online: Yesterday 11:28 PM Join Date: Apr 2004
Posts: 8,040
DNF$: 5,244 Location: On Earth
Country: | Good job Bender.
50 $F donated to your account. |
| |
10-26-2007, 04:28 PM
|
#9 (permalink)
| | DNF Member
Last Online: Yesterday 10:28 PM Join Date: Jul 2007
Posts: 401
DNF$: 1,113 Location: United States
Country: | 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. |
| |
10-26-2007, 04:55 PM
|
#10 (permalink)
| | www.LOL.biz
Name: Daniel Last Online: 07-07-2008 10:31 PM Join Date: Apr 2004
Posts: 1,783
DNF$: 5,162 Location: .ro
Country: | 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 |
| |
10-30-2007, 08:29 AM
|
#11 (permalink)
| | Platinum Lifetime Member
Name: Jason Last Online: 06-10-2008 02:27 PM Join Date: Nov 2006
Posts: 493
DNF$: 5,125 Location: USA
Country: | You could also do something like... Code: function pop_vals($associative_array) {
foreach ($associative_array as $key=>$val) {
eval('$'.$key.' = "'.$val.'";");
}
}
pop_vals($_REQUEST);
// $o should now be defined I do NOT recommend this, though, as someone could run...
YOURURL?o=|1&SOMEREMOTECOMMANDSHERE
Jason |
| | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| | | | All times are GMT -4. The time now is 01:00 AM.
Copyright @2001-2008 DNForum.com
|