I hope this is the right list as it concerns mysql and php ???
I just realized that an open connection is necessary to
usemysql_real_escape_string...So how do you sanitize an include page
used to open a connection
This is the page
// db1.php
// SQL login parameters for local environment
$local_dbhost     = "localhost";    // normally "localhost"
$local_dbuser     = "xxxx";    // your local database user name
$local_dbpass     = "xxxx";    // your local database password
$local_dbname     = "xxxx";    // your local database name

// SQL remote parameters for remote environment (ex: nomonthlyfees)
$remote_dbhost    = "localhost";    // normally "localhost"
$remote_dbuser     = "xxxx";    // your remote database user name
$remote_dbpass     = "xxxx";    // your remote database password
$remote_dbname     = "xxxx";    // your remote database name

// Local server address
$LOCAL_SERVER = "127.0.0.1";

// CONNECT to DATABASE
if ($_SERVER["REMOTE_ADDR"] == $LOCAL_SERVER) {
    $dbhost = $local_dbhost;
    $dbuser = $local_dbuser;
    $dbpass = $local_dbpass;
    $dbname = $local_dbname;
}
else {
    $dbhost = $remote_dbhost;
    $dbuser = $remote_dbuser;
    $dbpass = $remote_dbpass;
    $dbname = $remote_dbname;
}

$db = mysql_connect($dbhost, $dbuser, $dbpass);   
mysql_select_db($dbname,$db);

echo $dbname;
echo "<br>";
echo $dbhost;
echo $dbuser;
echo $dbpass;

if (!$db) {
    echo( "<P>Unable to connect to the " .
          "database server at this time.</P>" );
    exit();
  }

  // Select the database
if (! mysql_select_db("biblane") ) {
    echo( "<P>Unable to locate the biblane " .
          "database at this time.</P>" );
    exit();
  }
?>

-- 
unheralded genius: "A clean desk is the sign of a dull mind. "
-------------------------------------------------------------
Phil Jourdan --- p...@ptahhotep.com
http://www.ptahhotep.com
http://www.chiccantine.com/andypantry.php

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=arch...@jab.org

Reply via email to