shanejeffery86 Posted April 9, 2009 Share Posted April 9, 2009 Hey all. I am going to get straight to the point here. I have a test site and a live site that are both operating on the same server and use separate databases on the server. What is happening is that when a user goes from the test site to the live site or vice versa, the SQL connection from the previous site is still being used and a new connection is not being forced to open. So, for the time being, I am having to hardcode the SQL connection code into each page and we all know that that is terrible coding practice. I was researching mysql_connect and I found that there is a 4th parameter called $new_link. Apparently, if you set it to true, it would force a new connection even if the old connection is using the same parameters? Do I have my facts right? I do not mind having to force a new connection every time a new query runs as long as it is hitting the right database, which it is not at the moment. Quote Link to comment https://forums.phpfreaks.com/topic/153336-mysql_connect-4th-parameter-question-new-link/ Share on other sites More sharing options...
wildteen88 Posted April 9, 2009 Share Posted April 9, 2009 Yes setting the forth parameter to true will always yield a new connection. Quote Link to comment https://forums.phpfreaks.com/topic/153336-mysql_connect-4th-parameter-question-new-link/#findComment-805574 Share on other sites More sharing options...
PFMaBiSmAd Posted April 9, 2009 Share Posted April 9, 2009 use separate databases Are these two databases on the same database server, if so, then the problem is not in the connection (which would only do what you are stating if your were using mysql_pconnect()) but in the selection of the database the query is using. What is your code that is selecting the database? Quote Link to comment https://forums.phpfreaks.com/topic/153336-mysql_connect-4th-parameter-question-new-link/#findComment-805595 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.