warrenk Posted January 14, 2007 Share Posted January 14, 2007 I am trying to perform a redirect with the following code...<?php if ($suppid == "" or $compid == "") {$link = "http://www.yahoo.com";}else{$link = "http://www.yahoo.com";}endifheader("Location: $link");exit;?>When I run the page, it just sits on a blank screen. Am I doing something wrong? I know I have the same URL in my IF condition, this is for testing purposes only.Thanks for any help!Warren Quote Link to comment Share on other sites More sharing options...
Hughesy1986 Posted January 14, 2007 Share Posted January 14, 2007 Are you assining any values to $suppid or $compid?I just ran that code and it does not like the endif btwGlen Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted January 14, 2007 Share Posted January 14, 2007 Yes, it does't like the endif. In fact, ive never seen that syntax before, although it looks like you use it with colons instead of braces. Anyway, if i remove the end if and run the script, i get redirected to yahoo.com Quote Link to comment Share on other sites More sharing options...
warrenk Posted January 14, 2007 Author Share Posted January 14, 2007 I don't know what I am doing wrong. ??? I tried going to my page from a different computer (in case my redirect was being blocked) and still nothing.By the way here is the page...http://www.suppsearch.com/product.phpThe code is now...<?phpif ($suppid == "" or $compid == "") {$link = "http://www.suppsearch.com"}else{$link = "http://www.suppsearch.com"}header("Location: $link");exit;?> Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted January 14, 2007 Share Posted January 14, 2007 Im guessing that php insn't installed on that site. If you view the source you see your script, which isn't what should be happening.Try a file with just[code]<?phpphpinfo();?>[/code]in it Quote Link to comment Share on other sites More sharing options...
warrenk Posted January 14, 2007 Author Share Posted January 14, 2007 Here is the page with the PHPINFO...http://www.suppsearch.com/NewPage1.php Quote Link to comment Share on other sites More sharing options...
warrenk Posted January 14, 2007 Author Share Posted January 14, 2007 My host uses PHP Version 4.4.4. Would this be a reason for the redirect not working? Isn't the latest version 5.2? Quote Link to comment Share on other sites More sharing options...
Orio Posted January 14, 2007 Share Posted January 14, 2007 What about semicolons? You should also take out the $link out of the double quotes in the header():[code]<?phpif ($suppid == "" || $compid == "") $link = "http://www.suppsearch.com";else $link = "http://www.suppsearch.com";header("Location: ".$link);exit;?>[/code]Orio. Quote Link to comment Share on other sites More sharing options...
corbin Posted January 14, 2007 Share Posted January 14, 2007 If you want to use the endif syntax it must be likeif(condition)://do somethingendif;and as far as I know, else cannot be use with this method. Quote Link to comment Share on other sites More sharing options...
warrenk Posted January 14, 2007 Author Share Posted January 14, 2007 I tried the code...<?phpif ($suppid == "" || $compid == "") $link = "http://www.suppsearch.com";else $link = "http://www.suppsearch.com";header("Location: ".$link);exit;?>Now the script just shows up on the page. I think I may try a different host.http://www.suppsearch.com/product.phpWarren Quote Link to comment Share on other sites More sharing options...
Orio Posted January 14, 2007 Share Posted January 14, 2007 There's obviously no PHP support on this server. Like you said, try another host.Orio. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted January 14, 2007 Share Posted January 14, 2007 Well i dont quite understand, because it appears that there IS php support...As shown by the working link which contains phpinfo(); Quote Link to comment Share on other sites More sharing options...
warrenk Posted January 14, 2007 Author Share Posted January 14, 2007 Thanks for everyones help! I really appreciate all the feedback. Quote Link to comment 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.