Generally configuration files are used. For example,
/live.domain.com/conf/config.php
Would retain information specific to that instance of the application. Your application would NEVER call instance specific information from within scripts. Ie - you shouldn't hardcode DSN's, paths, email addresses, images, etc. All that information should be contained within a configuration file.
An example might be:
<?
$dsn_user = 'live';
$dsn_pass = 'live_password_1234234cx';
$dsn_host = 'localhost';
$dsn_type = 'mysql';
$dsn_db = 'live';
$site_name = 'Bob's Store [live]';
$admin = 'bob@bobsstore.com';
$debug = 0
?>
Then when you need a second site setup, you simply checkout of your revision control system (right?) into another directory, and edit the configuration file to reference the testing database.
It is generally bad practice to have a live and a development site share the same physical database (not database engine, its fine to host 50 sites on a single MySQL database server, but each site should have its own database WITHIN MySQL).
ideally you would have a setup file that could load in a series of test data and populate a new base system quickly.