Vivid Lust Posted December 22, 2007 Share Posted December 22, 2007 Heres my code: <?php $rand = srand(1,2); header('Location: banner.php?id='$rand); ?> Please can someone tell me where im going wrong. Thanks milions! Vivid Quote Link to comment https://forums.phpfreaks.com/topic/82808-solved-header-location-code-with-variable-not-working/ Share on other sites More sharing options...
Dane Posted December 22, 2007 Share Posted December 22, 2007 Are you outputting any HTML before using header() ? Quote Link to comment https://forums.phpfreaks.com/topic/82808-solved-header-location-code-with-variable-not-working/#findComment-421126 Share on other sites More sharing options...
Vivid Lust Posted December 22, 2007 Author Share Posted December 22, 2007 Umm, thats the whole of the code that will be in random.php This is for a random affiliate program im making. Quote Link to comment https://forums.phpfreaks.com/topic/82808-solved-header-location-code-with-variable-not-working/#findComment-421130 Share on other sites More sharing options...
Dane Posted December 22, 2007 Share Posted December 22, 2007 try <?php $rand = srand(1,2); header('Location: banner.php?id='.$rand.''); ?> change from srand to rand Quote Link to comment https://forums.phpfreaks.com/topic/82808-solved-header-location-code-with-variable-not-working/#findComment-421133 Share on other sites More sharing options...
Dane Posted December 22, 2007 Share Posted December 22, 2007 Actually This works <?php $rand = rand(1,2); header('Location: banner.php?id='.$rand.''); ?> Quote Link to comment https://forums.phpfreaks.com/topic/82808-solved-header-location-code-with-variable-not-working/#findComment-421135 Share on other sites More sharing options...
Vivid Lust Posted December 22, 2007 Author Share Posted December 22, 2007 Its not working for me :s http://imgsurf.wsnw.net/random.php Quote Link to comment https://forums.phpfreaks.com/topic/82808-solved-header-location-code-with-variable-not-working/#findComment-421139 Share on other sites More sharing options...
Dane Posted December 22, 2007 Share Posted December 22, 2007 Are you using the same code yes? Quote Link to comment https://forums.phpfreaks.com/topic/82808-solved-header-location-code-with-variable-not-working/#findComment-421140 Share on other sites More sharing options...
Vivid Lust Posted December 22, 2007 Author Share Posted December 22, 2007 i copy and pasted and it displayed the html white spaces All working fine now. Thanks muchly Quote Link to comment https://forums.phpfreaks.com/topic/82808-solved-header-location-code-with-variable-not-working/#findComment-421141 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.