ReeceSayer Posted December 8, 2009 Share Posted December 8, 2009 hi i was just wondering how i would go about including two connection files... I'm working on a project for university and i have to switch between connecting to my apache server and the university server. I want to make it so that the webpage connects to the correct database for which server its on... rather than having to constantly update 10 of my files to include connection2 rather than connection 1. Any help would be awesome thanks Quote Link to comment https://forums.phpfreaks.com/topic/184451-connecting-to-databases-if-statement/ Share on other sites More sharing options...
mikesta707 Posted December 8, 2009 Share Posted December 8, 2009 if ($_SERVER['HTTP_HOST'] == "localhost"){ //localhost connect } else { //server connect } Something like that should be about right, though you may want to use stristr instead of a straight equality comparison Quote Link to comment https://forums.phpfreaks.com/topic/184451-connecting-to-databases-if-statement/#findComment-973702 Share on other sites More sharing options...
ReeceSayer Posted December 8, 2009 Author Share Posted December 8, 2009 Thanks for the superfast reply ill make sure to test it out next week when i can test it on the uni server... Thanks Reece Quote Link to comment https://forums.phpfreaks.com/topic/184451-connecting-to-databases-if-statement/#findComment-973710 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.