Basically I want to have a file that can be called with a function to connect to my database. I am using MySQL 4 and PHP 5
here is my connect.php file:
<?php
function connect()
{
$db = new mysqli('localhost', 'mcneil', 'noway', 'it');
if (!$db)
throw new Exception('Could not connect to the database');
else
return $result;
}
?>
and i have been including this file and also trying "require_once"
the function is being called like so:
$db_conn = connect();
Finally, this line:
$result = $db_conn->query($query);
or any referring to the database gets the error:
Fatal error: Call to a member function query() on a non-object in C:\klatt.... etc etc
I cant figure this out for the life of me....
TIA,
Frank