I have a problem with a function that I'm trying to create, and it's supposed to connect to the database, but it doesn't! I have an include on the top of the file, where the mysql variables are, but when I refer to them in the function, they don't show up.
An example:
<?php
include("config.php");
function connect_to_db()
{
global $link;
$link = mysql_connect($host,$user,$pass);
if(!$link)
die(mysql_error());
mysql_select_db($db) or die(mysql_error());
?>
When this is executed I get this error:
"No Database Selected".
What's wrong?!