Okay, here's my situation.
In a script, i open the connection to the database and then use it in queries here and there throughout the script. Then comes a function that needs that same connection. It seems that connection should be available to the queries inside the function but it's not - something like this:
::
mysql_select_db( [needed bla info] );
include(functions.php);
$query = mysql_query();
$result = mysql_fetch_array($query);
function_needing_db();
mysql_close()
::
now inside function_needing_db(), it looks something like:
function function_needing_db(){
$query = mysql_query();
$result = mysql_fetch_array($query);
return $result["field"];
}
the database connection created at the top of the acutal script page doesn't appear to be available to the function when it is called.
I tried putting mysql_select_db( [bla] ) in an include and including it in the function defintion too, and it didn't work.
Does this just mean I need to repeat mysql_select_db() in the function definitions too? Is there a better way than opening all these database connections?