?
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
Medium Priority
?
192 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 200 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

WordPress Tutorial 2: Terminology

An important part of learning any new piece of software is understanding the terminology it uses. Thankfully WordPress uses fairly simple names for everything that make it easy to start using the software.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

801 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