Function variables - Been 2 years since i touched php
Posted: Wed Mar 28, 2007 7:54 pm
OK the $db variables are coming from config.inc.php
They echo before the fucntion, but not when i call the function.
So when i do db_connect(); on index.php it tries to connect but does not have the username etc.
Suggestions?
Thank you
They echo before the fucntion, but not when i call the function.
So when i do db_connect(); on index.php it tries to connect but does not have the username etc.
Code: Select all
<?PHP
include('config.inc.php');
echo $db_username;
echo $db_password;
echo $db_host;
echo $db_name;
// Functions page
//Connect to sql database
Function db_connect() {
$connection = mysql_connect($db_host, $db_username, $db_password) or die("Username/Password unable to connect to Mysql Datbase CHeck password/username/localhost");
$db = mysql_select_db($db_name, $connection) or die("unable to connect to database");
echo $db_username;
echo $db_password;
echo $db_host;
echo $db_name;
}
?>Thank you