View Single Post
Old Apr 2nd, 2007, 4:11 AM   #1
tAK
Programmer
 
Join Date: Mar 2007
Posts: 33
Rep Power: 0 tAK is on a distinguished road
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.
tAK is offline   Reply With Quote