I can't seem to get this to work, any idea why?
I have one function whose purpose is to connect to a DB:
Code: Select all
<?php
function connectDB() {
global $dbsettings;
$link = mysql_connect($dbsettings["host"], $dbsettings["user"], $dbsettings["pass"]);
mysql_select_db($dbsettings["dbname"]);
}
?>How do I get the $link variable to become accessible from that searchDB function?
The problem is, when I subsequently call disconnectDB():
Code: Select all
<?php
function disconnectDB() {
mysql_close($link);
}
?>I understand that you declare a variable as "global $var" at the beginning of a function to "import" that varialbe INTO that function, but how do you do the reverse - make a variable accessible OUTSIDE its function?
Thanks,
Peter.