Development Environments and PHP/MySQL

I recently installed WAMP to develop my website locally.
I’m new with PHP/MySQL and perhaps don’t entirely understand how connecting to mysql databases works with PHP.

How do most people set up their database locally? I assume that they mirror their production database tables.
If I need to connect to a server each time I do a SQL query (mysql_connect), and the development server is local but the real server is remote, how do I connect differently while testing and still be able to use that code?
Sorry if that’s not a good explanation. It seems that I would have to connect to localhost for testing, and www.example.com for production, which would require different code.

Answers or links to answers would be helpful!

For anyone who had the same question or just wants to point out mistakes/bad practices, I solved the problem by having a PHP file with a single function to return the servername. The file returns localhost on my local machine and the remote server name on the server code.

(this is the same person as above, I registered an account)

Just to add another solution for reference, you can have a PHP file that connects to the database (that can then be included on other files) then write-protect (remove write permissions) from the file on the server, so that it cannot be replaced.

Each file would then have its own connection information.

Can anybody provide me some data on php and how to work on it using database?
Bathroom Faucets

Sponsor our Newsletter | Privacy Policy | Terms of Service