|
mysqli connect via included file
Hey guys,
i have around 7 pages that all connect to the same database, at the moment, i have been adding this:
$mysqli = new mysqli('localhost','root','password');
$mysqli->select_db('mydatabase');
to the top of every script, i also have a "functions.php" which i include which contains some custom functions.. i tried adding this to functions.php:
function connect_db(){
$mysqli = new mysqli('localhost','root','password07');
$mysqli->select_db('tassielans');
}
and replacing the db connect lines with connect_db();
but it didnt work.. i realise this is most definitely wrong (not just because it didnt work)
but i was wondering if anyone has a function that works for connecting to a database via mysqli ?? or a link to a site that explains it well, so far my web searches haven't turned up anything new on the topic.
|