By link I mean, I'm sorry I thought it was fairly common reference to call this connection variable a link.
$link = @mysql_connect('localhost', 'user', 'password') or die("Could not connect to MySQL");
By pass a parameter I mean
//start main
function1($link)
//end main
function function1($link)
{
do some stuff;
function2($link);
}
function function2($link)
{
do some stuff;
function3($link);
}
function function3($link)
{
do some stuff;
function4($link);
}
function4($link)
{
mysql query involving link;
}
by use sessions I mean
//start main
$_SESSION['link']=$link;
function1();
//end main
function function1()
{
do some stuff;
function2();
}
function function2()
{
do some stuff;
function3();
}
function function3()
{
do some stuff;
function4();
}
function4()
{
$link=$_SESSION['link'];
mysql query involving $link;
}
So in the first you're just kind of passing $link through all the other functions even though it's not needed there you never call the end function explicitly from main. In the second you avoid doing this by putting it in session data. I was wondering if one or the other of these two methods is preferable.