![]() |
test to live with mysql_connect_db
Some advice please.
I have a testing server at localhost, after making amendments fixing bugs etc. I upload to a hosted web server. Problem is I have to change all the mysql_connect_db statements before uploading due to parameter 1 of the mysql_connect_db statement on the testing server being set to "localhost" and on the live server it's info provided by the web hosting company. Is there any way I can set something in my localhost testing environment (or a completely different method) that simulates the same as the live environment |
I see what you mean and I found this hassle. How many times are you calling that function? Do you have multiple databases or just one?
Just upload your local version. When it is live, go into your host directories and manually edit all the connection stuff. Then you've only done it once and you also keep a copy of your original localhost versions of the files. Once you got a live version, you can work locally, then just copy paste the code into your live version by going into the bit where you upload and editing the file which is online directly. Hope it helps. Maybe someone can give you better information and good tips to keep in mind. This is what I do but I'm no expert. Regards, LC. |
Poeple do this is several ways, personally I use a include file, while other use a function call.
it goes something like this, you just edit file to which host its on. file 'db.php' PHP Code:
PHP Code:
|
Keep one configuration file name config_db.php or any name when you want to connect database to outer pages just include it
config_db.php $con=mysql_connect('localhost','root','pass')or die("Could not Connect"); $select=mysql_select_db('database name',$con); after you test your site using localhost before upload it to server just change config_db.php values localhost, root,pass and database name :o:o:o:o:o |
Just a suggestion, but I use a constant named LOCAL and just set it to true or false to switch between localhost and live - saves having to edit, or comment out, all the other details:
PHP Code:
|
What a great idea, would save A LOT of messing about.
Regards, Lc. |
| All times are GMT +1. The time now is 07:10 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.