pvmatrix Posted September 21, 2007 Share Posted September 21, 2007 Is it possible to use the same database connection throughout the whole application instead of creating db connection in every page? I tried to pass the db connection through session variable. It appears it closes the the db connection after execution of the sql query. I ended up creating connection in every page. Any suggestions? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/70093-passing-database-connection-between-pages/ Share on other sites More sharing options...
itdmacar Posted September 24, 2007 Share Posted September 24, 2007 Hi, I am still new to this as well but this what I have done, I have put them into the Include . . . 1) new includefile.php <?php $hostname_con_recorenq = "localhost"; $database_con_recorenq = "test"; $username_con_recorenq = "usera"; $password_con_recorenq = "passworda"; $con_recorenq = mysql_pconnect($hostname_con_recorenq, $username_con_recorenq, $password_con_recorenq) or die(mysql_error()); ?> ") then in my actual file, just add this command, <?php require_once('includefile.php'); ?> Not sure if this is the best option but it works for me, others may have other ideas beside this . . . Quote Link to comment https://forums.phpfreaks.com/topic/70093-passing-database-connection-between-pages/#findComment-354081 Share on other sites More sharing options...
rich11 Posted October 19, 2007 Share Posted October 19, 2007 is there like an application variable that php will automatically seek out. In coldfusion the application.cfm holds the database connection plus any session variables you are wanting to work with. Rich Quote Link to comment https://forums.phpfreaks.com/topic/70093-passing-database-connection-between-pages/#findComment-373349 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.