Page 1 of 1

Quick Question

Posted: Thu Apr 08, 2010 6:04 am
by cloggin55
I"m trying to pass some code through a redirect and I'm getting an error.
Anyone have any suggestion?

This is the redirect with the code

<?
$urls = array(
"http://url1.com/?id=<?php echo str_replace('-', ' ', $_GET['id'])?>",
"http://url2.com/?id=<?php echo str_replace('-', ' ', $_GET['id'])?>");
$url = $urls[array_rand($urls)];
$destination = "Location: $url";
header($destination);
?>

Any help is much appreciated.

Thanks!

Re: Quick Question

Posted: Thu Apr 08, 2010 7:10 am
by dejvos
I think this will work.

Code: Select all

<?
$urls = array(
"http://url1.com/?id=".str_replace('-', ' ', $_GET['id']),
"http://url2.com/?id=".str_replace('-', ' ', $_GET['id'])
);
$url = $urls[array_rand($urls)];
$destination = "Location: $url";
header($destination);
?>

Re: Quick Question

Posted: Thu Apr 08, 2010 7:34 am
by Turv
cloggin55 wrote:I"m trying to pass some code through a redirect and I'm getting an error.
Anyone have any suggestion?

This is the redirect with the code

<?
$urls = array(
"http://url1.com/?id=<?php echo str_replace('-', ' ', $_GET['id'])?>",
"http://url2.com/?id=<?php echo str_replace('-', ' ', $_GET['id'])?>");
$url = $urls[array_rand($urls)];
$destination = "Location: $url";
header($destination);
?>

Any help is much appreciated.

Thanks!
You are opeing PHP Tags from within another PHP Tag, Look up PHP String Concatenation