Hi All, my first post 😃
I am writing a PHP driven site. I wish for the site to rely on common include files for common tasks such as: -
Connecting to a Database
Displaying Data Sources
I have one file which has the database connecting code called: -
DatabaseConnect.php3: -
Consists of a function called OpenConnection(Simply connects to a database) & Close Connection(Closes a connection to a database).
<?PHP
function OpenConnection(){
//DATABASE VARIABLES
$password='root';
$hostname='localhost';
$databasename='DrumBase';
//CONNECT TO DATABASE
$connection = @mysql_connect($hostname, $password);
//SELECTS THE DATABASE THAT WE WISH TO USE
mysql_select_db($databasename);
}
function CloseConnection()
{
//CLOSE CONNECTION
mysql_close();
}
?>
Default.php3: -
Consists of the HTML page, and the PHP code to include the file above.
<?PHP
include_once("http://localhost/Test/PHP/DatabaseConnect.PHP3");
OpenConnection();
?>
How come when I try to run the function 'OpenConnection' the page generates the error: -
Fatal error: Call to undefined function: openconnection() in C:\Program Files\Apache Group\Apache2\htdocs\Test\default2.php3 on line 6
I thought all that 'include' function did was replace the specified code with the 'include function'. Shouldn't the OpenConnection() function run since the code for it has been placed in the file by the 'include' function?
Thanks for any help in advance!