osf2008 Posted May 9, 2008 Share Posted May 9, 2008 I run two websites that utilise the same information and would like to merge the files. I have tried it myself and can't get it working. What I am hoping to do is if ($_server = "site 1") { print "content 1"} else { print "content 2"} Link to comment https://forums.phpfreaks.com/topic/104832-if-else-statement-with-_server/ Share on other sites More sharing options...
DyslexicDog Posted May 9, 2008 Share Posted May 9, 2008 Have you tried echoing the $_SERVER var you're using to verify you get two different strings? Link to comment https://forums.phpfreaks.com/topic/104832-if-else-statement-with-_server/#findComment-536609 Share on other sites More sharing options...
osf2008 Posted May 10, 2008 Author Share Posted May 10, 2008 Yes, and the individual www.sitename.co.uk's appear. Link to comment https://forums.phpfreaks.com/topic/104832-if-else-statement-with-_server/#findComment-537444 Share on other sites More sharing options...
DyslexicDog Posted May 12, 2008 Share Posted May 12, 2008 Did you try making sure you have the same capitalization ? i.e. if (strtolower($_server) = "site 1") { print "content 1"} else { print "content 2"} Link to comment https://forums.phpfreaks.com/topic/104832-if-else-statement-with-_server/#findComment-538715 Share on other sites More sharing options...
trq Posted May 12, 2008 Share Posted May 12, 2008 Would you like to try posting your actual code so we can stop guessing what your issue might be? Link to comment https://forums.phpfreaks.com/topic/104832-if-else-statement-with-_server/#findComment-538736 Share on other sites More sharing options...
osf2008 Posted May 15, 2008 Author Share Posted May 15, 2008 The code I have used is: if ($_SERVER['SERVER_NAME'] = www.sitea.com) { $maintext = "Site A text" } else { $maintext = "Site B text" } Kind regards Stephen Link to comment https://forums.phpfreaks.com/topic/104832-if-else-statement-with-_server/#findComment-541621 Share on other sites More sharing options...
redarrow Posted May 15, 2008 Share Posted May 15, 2008 use full url please try that http://www.what_ever.com Link to comment https://forums.phpfreaks.com/topic/104832-if-else-statement-with-_server/#findComment-541624 Share on other sites More sharing options...
osf2008 Posted May 15, 2008 Author Share Posted May 15, 2008 I have tried that and still get the same problem. Kind regards Stephen Link to comment https://forums.phpfreaks.com/topic/104832-if-else-statement-with-_server/#findComment-541646 Share on other sites More sharing options...
blueman378 Posted May 15, 2008 Share Posted May 15, 2008 doesnt this have to be in quotes? well it wont work because your if statment only has one = not two so it is setting the variable, try if ($_SERVER['SERVER_NAME'] == "www.sitea.com") { $maintext = "Site A text" } else { $maintext = "Site B text" } and please next time use the [ code ] [/ code ] tags Link to comment https://forums.phpfreaks.com/topic/104832-if-else-statement-with-_server/#findComment-541724 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.