Solved

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

Posted on 2007-03-21
3
184 Views
Last Modified: 2008-02-07
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
Comment
Question by:Alpha_AI
3 Comments
 
LVL 5

Expert Comment

by:Oscurochu
ID: 18768708
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
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 18769433
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
 
LVL 14

Accepted Solution

by:
raja_ind82 earned 50 total points
ID: 19657377
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now