• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 196
  • Last Modified:

How do i set my config file so my files I upload from my localhost wont bring up any mysql connection problems?

Hello,

I have a remote testing server and my local testing server. At the moment i am making changes to php files and uploading them back to the web so i am making changes and testing that way.
It is too slow for me and I dont like to upload all the time.
I have the same database on my pc and on the web but both have different login and password.
How can I set it up so that when i make changes on the local computer i can upload it without any database connectivity problems.

I have seen some code but i dont know what it means and how it works.

// Database setting
$host = "localhost";

if ($_SERVER["LOCAL_ADDR"] == "192.6.0.1")  // I changed the ip address
{
$database = "db_cars";
$db_username = "cars";
$db_password = "123";
define('DIR_WS_CATALOG', '//server1/web/carssite.com/website/'); //Static Path
define('DIR_FS_CATALOG', 'http://server1/web/carssite.com/website/'); // Virtual path
}
else
{
$database = "db_youraccess_cars";
$db_username = "carscars";
$db_password = "cars"; // i changed passwords

also does any know what the two codes below do?

define('DIR_WS_CATALOG', '//server1/web/carssite.com/website/'); //Static Path
define('DIR_FS_CATALOG', 'http://server1/web/carssite.com/website/'); // Virtual path
0
Alpha_AI
Asked:
Alpha_AI
1 Solution
 
OscurochuCommented:
making the usernames and passwords the same, and try to make your local server as close to the remote server as possible.

the two codes however, i don't know what they are for because i dont know how your whole script is written...
0
 
Jason C. LevineNo oneCommented:
Hi Alpha_AI,

I would put the connection strings into a separate file and call it with a php include statement.  You then have two versions of the file...one for the local DB and one for the remote DB and you never, ever upload the include file once these are set.

Assuming the paths on the local and remote are identical, when you upload the main PHP file, it will use the login information of the include file on the remote server.
0
 
raja_ind82Commented:
i hope this will works for you................

<?php
define("LOCAL_SERVER_NAME","w2kserver");

if(substr_count($_SERVER['SERVER_NAME'], LOCAL_SERVER_NAME)>0)
{
      define("SITE_MODE","development");
      //Master Database Connectivity
      define("MASTER_DATABASE","Local_database");
      define("DATABASE_SERVER","localhost");
      define("DBUSER","local_user");
      define("DBPASS","local_pass");
}
else if(substr_count($_SERVER['SERVER_NAME'], "Yourservername or ip")>0)
{
      define("MASTER_DATABASE","remote_database");
      define("DATABASE_SERVER","localhost");
      define("DBUSER","remote_user");
      define("DBPASS","remote_pass");
}
$DB_LINK = mysql_connect(DATABASE_SERVER, DBUSER, DBPASS,1);
mysql_select_db(MASTER_DATABASE, $DB_LINK);
?>

Regards,
M.Raja
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now