PHP - Redirect not working correctly

Hi Guys,

I need your help please. I’m trying to load a URL like the following:

Now as you can see in the url i have the following:


Here is my code:

if ( $lp == "1" ) {

if ( $lp == "2" ) {

if (isset($lp)) {
    //do nothing
} else {

@mysql_select_db($database) or die( "Oops theres an error, our highly trained monkeys have been notified.");

$query = sprintf("SELECT URL FROM programs WHERE ID ='%s'",

mysql_query($query) or dies(mysql_error());
$result = mysql_query($query);
$url=mysql_fetch_array($result, MYSQL_ASSOC);


$string =$url['URL'];
$string = addslashes($string);
$urlgo=eval("\\$string = \\"$string\\";");
header( 'Location: '.$string.'' ) ;

There is more code than the above such as connecting the the database and variable setting but i the i think with the above you can see what im trying to do. But how ever when i try the URL above with the &lp=1 it just takes me to:

and not the URL thats in the script. Can someone help me please and tell me where im going wrong?

Thank you.

I’m not sure why you have addslashes and eval there. What happens if you just do:

$string = $url['URL']; 
header( 'Location: '.$string ); 


I was told to do that as sometimes the URL will have a variable in it for example$affid

But when loading the URL $affid wasnt being replaced with the data thats stored in that variable and was just sending people to the URL with the variable as PHP code. So i was told to do that and then it started to work.

Any help with this guys would be much appreciated.

Thank you!