Guest upirate Posted March 30, 2007 Share Posted March 30, 2007 I have a page that has a connection to a database. I also call a function that makes a connection to a new database, outputs some data and closes. The problem: When I call the function, the main page database seems to not pull any data at all. Im using all new database connection variables and closing them. Still the main connection stops working. Quote Link to comment https://forums.phpfreaks.com/topic/44947-solved-database-connection-from-within-a-function/ Share on other sites More sharing options...
obsidian Posted March 30, 2007 Share Posted March 30, 2007 When you say you are using all new database connection variables, you need to also make sure you are telling mysql to open a new connection. So, within your function, you need to make sure you have declared TRUE within your mysql_connect() function call for your fourth parameter: <?php $con1 = mysql_connect($host, $user, $pass); // First connection $con2 = mysql_connect($host, $user, $pass, TRUE); // force a new connection ?> Hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/44947-solved-database-connection-from-within-a-function/#findComment-218232 Share on other sites More sharing options...
Guest upirate Posted March 30, 2007 Share Posted March 30, 2007 thanks man. Let me try it out. Quote Link to comment https://forums.phpfreaks.com/topic/44947-solved-database-connection-from-within-a-function/#findComment-218241 Share on other sites More sharing options...
Guest upirate Posted March 30, 2007 Share Posted March 30, 2007 worked like a charm. thanks bud Quote Link to comment https://forums.phpfreaks.com/topic/44947-solved-database-connection-from-within-a-function/#findComment-218248 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.