Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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
?
194 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
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…
Suggested Courses

636 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