$GLOBAL mysql_connect from include()
Posted on 2007-09-30
Hi all. I'm learning php and can't figure this out.
From home.php I am calling functions.inc.php where within functions.inc.php I have the following:-
// Check server connection status. Provide message if fault.
Sorry, at the moment we are unable to connect to the server at this time.'."\n".'<body>'."\n".'<html>';
If I try and use this from within home.php am not getting $conn as GLOBAL
As this is the case, if I try the following mysql_select_db($db,$conn) the script breaks and I receive the following.
Notice: Undefined variable: conn in D:\htdocs\Nusphere\register-user.php on line 68
Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'ODBC'@'localhost' (using password: NO) in D:\htdocs\Nusphere\register-user.php on line 69
Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in D:\htdocs\Nusphere\register-user.php on line 69
Sorry, we are unable to connect to the database at the moment. Please try later..
I know that this is a scope problem but can't see how I need to change the function so that it works.
Help much appreciated.