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
179 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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.

746 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