andrewgarn Posted May 29, 2008 Share Posted May 29, 2008 Right so I signed up to web hosting with mysql server, but they dont allow access to the database from outside their server. I wish to test pages offline using my local mysql server but dont want to have to change the connection details every time I upload the page. So I figured an IF function for the db connect, however I dont know what the constraint would be, ie. how it would identify where the page would be accessed from. I use 3 web urls: localhost, a no-ip domain and the hosting service (freehostia) //Database Information $dbhost = "*"; $dbname = "*"; $dbuser = "*"; $dbpass = "*"; Any suggestions? This is probably simple I just dont know syntax for the if function Link to comment https://forums.phpfreaks.com/topic/107847-solved-if-function-for-db-connection/ Share on other sites More sharing options...
rhodesa Posted May 29, 2008 Share Posted May 29, 2008 Even easier, have an included file (like dbconnect.php) with the connection info specific for that server. Then, have your pages include that file. Link to comment https://forums.phpfreaks.com/topic/107847-solved-if-function-for-db-connection/#findComment-552835 Share on other sites More sharing options...
andrewgarn Posted May 29, 2008 Author Share Posted May 29, 2008 But that wouldnt solve the problem of which mysql server to connect to? Link to comment https://forums.phpfreaks.com/topic/107847-solved-if-function-for-db-connection/#findComment-552839 Share on other sites More sharing options...
rhodesa Posted May 29, 2008 Share Posted May 29, 2008 yes it would...so on your webserver, your copy of dbconnect.php has your local mysql info. and on the hosted service, the dbconnect.php file has the info for the hosted mysql server. Link to comment https://forums.phpfreaks.com/topic/107847-solved-if-function-for-db-connection/#findComment-552842 Share on other sites More sharing options...
andrewgarn Posted May 29, 2008 Author Share Posted May 29, 2008 oh of course. so simple, stupid me Thanks Link to comment https://forums.phpfreaks.com/topic/107847-solved-if-function-for-db-connection/#findComment-552843 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.