Hi, what's a good way of passing db connection from scirpt to script? is session_register a good way of doing it? thanks steve
create a php file with the vars
$connection = "localhost"; $user_name = "root"; $user_pass = ""; $database = "database";
save as cfg.php
now in each page add this tothe top of the page
include('cfg.php');
$db_connection = mysql_pconnect(.....); i'm trying to pass $db_connection from one script to another. my register_globals are off.
why not just include or require it?
throw $db_connection = mysql_pconnect(.....);
into cfg.php
then each page where you want $db_connection = mysql_pconnect(.....);
i thought that mysql_pconnect suppose to be persistent. if i call this function on every page, won't there be some overhead in looking for already opened connection.
isn't there a way to hand over the connection from script to script?
thanks, steve
if i call this function on every page, won't there be some overhead in looking for already opened connection.
Of course, there is overheard for everything, including defining variables. But the overheard of looking for an already opened connection is much smaller than the overheard of creating a new connection. That's where you save time.
Diego
thanks, it works