Alanmoss Posted June 11, 2006 Share Posted June 11, 2006 Hi , Can someone tell me why this script redirects <?$var = 3;if($var = 2) { header ("Location: page2.php"); exit(); } else { echo'<p>Page 1 end</p>';} ?>Thanks, Alan. Quote Link to comment https://forums.phpfreaks.com/topic/11737-header-location/ Share on other sites More sharing options...
AndyB Posted June 11, 2006 Share Posted June 11, 2006 Because you actually wanted to test $var using the equality operator (==) not the assignment operator (=), and the assignment is always true. Try this instead:[code]if ($var==2) { do whatever ... [/code] Quote Link to comment https://forums.phpfreaks.com/topic/11737-header-location/#findComment-44395 Share on other sites More sharing options...
Alanmoss Posted June 11, 2006 Author Share Posted June 11, 2006 Thanks very much and it was a mistake , i did not mean to post it twice but i didn't think it was posted firts time .Thanks, alan Quote Link to comment https://forums.phpfreaks.com/topic/11737-header-location/#findComment-44404 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.