nadav_rock Posted May 8, 2020 Share Posted May 8, 2020 i test codes using remote connection ot host gator. but have to each time uncomment to swtich it back to connection that would work live on server. is there a solution such as try remote connection catch regular connection? $conn = mysqli_connect("50.87.155.149", "nadavrock", "xxx", "nadavroc_personal_website"); // $conn = mysqli_connect("localhost", "nadavrock", "xxx", "nadavroc_personal_website"); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } Quote Link to comment Share on other sites More sharing options...
Barand Posted May 8, 2020 Share Posted May 8, 2020 First, tell mysqli to throw exceptions on errors mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); then try{} it. Quote Link to comment Share on other sites More sharing options...
benanamen Posted May 8, 2020 Share Posted May 8, 2020 All you need is a simple if else checking $_SERVER['HTTP_HOST'] and setting the connection parameters accordingly Quote Link to comment Share on other sites More sharing options...
nadav_rock Posted May 8, 2020 Author Share Posted May 8, 2020 i am new to php. can you give me the code for the simple if else statment? Quote Link to comment Share on other sites More sharing options...
benanamen Posted May 8, 2020 Share Posted May 8, 2020 2 hours ago, nadav_rock said: i am new to php. can you give me the code for the simple if else statment? Since you are new, you may not know the authors of Php have offered a free manual. You will need to refer to this manual all throughout your programming journey so best to bookmark it. Php Manual. Here is the specific manual page that will teach you about if/elsif/else.https://www.php.net/manual/en/control-structures.elseif.php Quote Link to comment Share on other sites More sharing options...
nadav_rock Posted May 9, 2020 Author Share Posted May 9, 2020 i know what an if else statement is. i dont know what you meant by $_SERVER['HTTP_HOST']. can you give me a working code? 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.