Jump to content

[SOLVED] Best way the same DB locally and online.


Maracles

Recommended Posts

I'm new to PHP so haven't quite worked out the work flow properly yet, as such I have a question regarding MySQL databases.

 

For the last couple of weeks I have been making a site offlline and testing on local host, now however I want to upload it to my live test website (password protected) and have done so including uploading the MySQL file.

 

This however caused a problem because the 'mysql_select_db query()' was configured for localhost and not my live server therefore the live page could not initially connect to the database. Therefore to get it working I need to change the code however in doing so it becomes quite frustrating because:

 

  a. It would mean I need one set of files with database connection configured for the live server and one set of files for testing   

  which are configured for the local host.

 

  b. In turn if I was testing locally and getting certain pages ready, every time I wanted to upload the changes I would have to make 

  copies that included the right database connect code and upload this to the website.

 

Is there a easier workflow for creating and testing files locally but then still having an easy way of uploading them and have all the database connections work smoothly? Basically I want to work locally on my laptop even when disconnected from the laptop and then when a page is finished simply upload it straight to my site and have it working.

 

I know this is badly described but i'm sturggling to explain it :-S!

 

what i do is i write a db connection file that has all my db info with the same name both local and online then you just include the connection file and when you upload your site(not the db connection file) it will include the appropriate db connection settings without having to change your scripts

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.