Hi, I'm trying to include a file which contains a simple db connection script. But it keeps giving me the error no db selected, as if the file was never included. Here are both my files. Do you see anything wrong?
mainfile.php
include("functions/db_conn.php");
// Now check to see if there is someone with that user name already in the database
$check_name = "select * from user where user_name = '$user_n'";
$result = mysql_query($check_name);
if (!$result)
{
die('Invalid query: ' . mysql_error());
}
db_conn.php
<?php
function ConnectToDb()
{
//connect to the db server
$conn = mysql_connect('localhost', 'victorb_victor', 'mrbo');
if (!$conn)
{
die('Could not connect: ' . mysql_error());
}
//successfully connected to server
// make victorb17 the current db
$selected_db = mysql_select_db('victorb_victorb17', $conn);
if (!$selected_db)
{
die ('Can\'t use database! : ' . mysql_error());
}
//connected to database
}
?>
Thanks!