Testing Server database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

bradles
Forum Commoner
Posts: 89
Joined: Wed Jun 30, 2004 10:40 pm

Testing Server database

Post by bradles »

I am using dreamweaver with a testing site and also to deploy my site once I am happy with any updates.

I have php & mysql installed on my localhost server and I was wondering if it is possible to be able to add a database that I can test on my localhost server and then upload to my www server without having to change any code.

I guess this will require the php script to determine if it is on the localhost or on the www host and I would have to have the same directory path on my local machine mimicking the path to the database on the www host.

Sorry if this isn't making any sense. My goal is to be able to set up an exact working duplicate of my site (database and all) on my local machine so I can test it and then deploy it to the www.

Do I need to contact my host provider to find out where they store my databases?

Brad.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

most mysql databases are hosted on localhost even for web servers.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

the only thing you'd need to worry about (if the mysql database is on localhost) is login, password and database name which might be different on your hosting server.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I tend to match all those up, cause I'm lazy :P
bradles
Forum Commoner
Posts: 89
Joined: Wed Jun 30, 2004 10:40 pm

Post by bradles »

So do I need to add a MySQL database setting it up through my cpanel and then mimick everything on my testing server? Or can I set up the database and everything on my local machine and then just upload it?

Brad.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

yup same here. I tend not to set a password and leave the login at the default "root" - a special bit of laziness on my part which broke an online application for a day because I didn't test it afterwards. Makes the old adage: "If it's not tested, it's broken" even more true...
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

bradles wrote:So do I need to add a MySQL database setting it up through my cpanel and then mimick everything on my testing server? Or can I set up the database and everything on my local machine and then just upload it?

Brad.
First set up the db on the remote server, then mimick everything on your localhost.
bradles
Forum Commoner
Posts: 89
Joined: Wed Jun 30, 2004 10:40 pm

Post by bradles »

patrikG wrote:First set up the db on the remote server, then mimick everything on your localhost.
Does that mean I can edit the database on my local machine? Or do I have to test my site, upload php, go into cpanel and edit database manually. That would seem like double handling.

Brad

[EDIT] I just got an email back from tech support saying:
Well although the path to the databases is /x/y/z/databasename you do not have explict access to the above path. Using the phpmyadmin from your mysql feature, you can manage the mysql database and upload your database.
Not sure what I do now.
Breckenridge
Forum Commoner
Posts: 62
Joined: Thu Sep 09, 2004 11:10 pm
Location: Breckenridge, Colorado

Post by Breckenridge »

Yes you can edit databases on your own machine and this is how you do it:

1. on your server set an sql user called remotedbuser or anyname you want with your network ip as the host UNDER THE users TABLE.

2. allow the user your created permissions to your database in the db table.

3. when you connect to your server use the ip of your server vs your server name

code and change/update your databases as you please from code running on your local computer.

need more help private message me
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

that'd work if the server db user has remote access rights.. not many installs allow that, esp with cpanel installations.
bradles
Forum Commoner
Posts: 89
Joined: Wed Jun 30, 2004 10:40 pm

Post by bradles »

How do you go about it feyd?

In particular, after tech support sent me the following information:
Well although the path to the databases is /x/y/z/databasename you do not have explict access to the above path. Using the phpmyadmin from your mysql feature, you can manage the mysql database and upload your database.
I'm stuck on how to set this up. They have told me the folder path is /x/y/z/databasename but those folders are not in my www path.

Brad
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

correct.. check your servers root path...
bradles
Forum Commoner
Posts: 89
Joined: Wed Jun 30, 2004 10:40 pm

Post by bradles »

Phenom wrote:correct.. check your servers root path...
So I just have to add "/x/y/z/databasename" to the root path in order to access the database?

Brad
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

when I want to bring over the stuff.. I make it on the server, export the data, and import it into my local server.
bradles
Forum Commoner
Posts: 89
Joined: Wed Jun 30, 2004 10:40 pm

Post by bradles »

feyd wrote:when I want to bring over the stuff.. I make it on the server, export the data, and import it into my local server.
Feyd, can you then add tables etc to the database on your local server and update the changes to the db on the www? Or do you have to manually go into the www db and add the new tables and any edits etc?

Brad
Post Reply