<pre>
<?
define(LOGIN,"user");
define(PASS,"pass");
define(DB,"mysql");


function dblogin($login,$pass,$db)
{
    $mysql = mysql_connect("localhost",$login,$pass);
    mysql_select_db($db,$mysql);
}
?>
</pre>

If you're trying to protect your login credentials, you could create a class for performing mysql actions. Then put the credentials into private/protected members or constants.


<?php

// This is an example.  Using protected members instead of constants would be
// more flexible (you can extend the class with wrappers for each database).
class MySQL {
  const HOST = 'your_DSN';
  const USER = 'Monty_Python';
  const PASS = 'Your_father_was_a_hamster_and_your_mother_smelled_of_elderberries';

  function __construct() {
    $this->connect();
  }

  function connect () {
    mysql_connect(self::HOST, self::USER, self::PASS);
  }
  // query methods, etc.
}

?>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to