#native_company# #native_desc#
#native_cta#

Apache on WIN32 Page 5

By Brian Moon
on July 30, 2000

A Tip For Database Users
All this is fine and good if all you do is put together pages with PHP.
But what if you need to access a database, such as MySQL, that is on a server on
the internet somewhere. Well, if you have remote connections allowed, you
can connect to them from your local box. I created a single file to
include in all my MySQL operations to handle connecting to the database. It
looks like this:

<?php

if (!defined"_DB_INI" ) ) {

  define("_DB_INI");

  $dbName "brian";

  if (!strstr($HTTP_HOST"brian.threadnet.com")) {

    
$dbUser "brian";

    
$dbServer "brian.threadnet.com";

    
$dbPass "password";

  } else {

    
$dbUser "brian";

    
$dbServer "";

    
$dbPass "password";

  }

  
$dbConn mysql_pconnect($dbServer$dbUser$dbPass);

}

?>



As you can see, I have a section of connecting locally
(files on the server) and remotely (files on my machine).
This allows me to have different passwords or even usernames for connecting locally and remotely.
So, now I can develop with database connectivity and still not have
to upload to the server.
Well, that should get you going. Using Windows as a development
environment can be very nice. It seems some think it is a sin to use Open
Source software on the Windows platform. Don’t listen to
them.
–Brian

1
|
2
|
3
|
4
|
5