verdrm Posted February 23, 2008 Share Posted February 23, 2008 If I require_once a MySQL connection script on each page of my website, does that mean a new connection is being made each time? What is the best way to minimize the amount of connections being made to the database? Quote Link to comment https://forums.phpfreaks.com/topic/92625-mysql-connection-script/ Share on other sites More sharing options...
budimir Posted February 23, 2008 Share Posted February 23, 2008 You can either use include function! Also, if you are worried about the number of connections on your database, you can close the connection after you have finished your query! Quote Link to comment https://forums.phpfreaks.com/topic/92625-mysql-connection-script/#findComment-474726 Share on other sites More sharing options...
verdrm Posted February 23, 2008 Author Share Posted February 23, 2008 Isn't require_once a little safer? Is there a big difference between include and require_once? Quote Link to comment https://forums.phpfreaks.com/topic/92625-mysql-connection-script/#findComment-474729 Share on other sites More sharing options...
budimir Posted February 23, 2008 Share Posted February 23, 2008 How do you mean safer? What do you want to achieve? Give me some more details about what are you doing! Quote Link to comment https://forums.phpfreaks.com/topic/92625-mysql-connection-script/#findComment-474733 Share on other sites More sharing options...
verdrm Posted February 23, 2008 Author Share Posted February 23, 2008 OK, by safer I mean that include will not stop the page from loading if the file is not present, but require_once will not allow the page to be processed normally if, for example, the required connection file is not found. Basically, my hosting provider (GoDaddy) claims that I have 50 simultaneous MySQL connections available per user. What does that mean? Does that mean only 50 people can access my website at once (because the data comes from MySQL)? Are there ways to get around that? I need to figure out how to optimize my scripts so only one connection is being made per user. If I have six pages, each with require_once connection script, does that mean six connections are being made that are not closed when the user goes to another page? Quote Link to comment https://forums.phpfreaks.com/topic/92625-mysql-connection-script/#findComment-474740 Share on other sites More sharing options...
jazz Posted February 23, 2008 Share Posted February 23, 2008 If I require_once a MySQL connection script on each page of my website, does that mean a new connection is being made each time? What is the best way to minimize the amount of connections being made to the database? No. It means that whenever the code of that script is called (e.g. it contains functions) and it connects to MySQL, it connects to MySQL. Roughly: Calls = Total calls to the script * mysql connections that the scripts uses Quote Link to comment https://forums.phpfreaks.com/topic/92625-mysql-connection-script/#findComment-474771 Share on other sites More sharing options...
verdrm Posted February 23, 2008 Author Share Posted February 23, 2008 I'm still slightly confused. If the user logs in, and the home.php page has require_once, is that a connection? Then, if they click on another page that has require_once, is that another connection? How does that work? Also, what would my hosting provider mean by 50 simultaneous MySQL connections per user? Quote Link to comment https://forums.phpfreaks.com/topic/92625-mysql-connection-script/#findComment-474774 Share on other sites More sharing options...
jazz Posted February 23, 2008 Share Posted February 23, 2008 I'm still slightly confused. If the user logs in, and the home.php page has require_once, is that a connection? Then, if they click on another page that has require_once, is that another connection? How does that work? Also, what would my hosting provider mean by 50 simultaneous MySQL connections per user? You don't need to worry. 50 SIMULTANEOUS MySQL connections is GOOD. You 'll need to have a lot of people visiting your site to need an upgrade in hosting. A require_once tells you nothing about how many connections the script does to the MySQL server. Quote Link to comment https://forums.phpfreaks.com/topic/92625-mysql-connection-script/#findComment-474778 Share on other sites More sharing options...
verdrm Posted February 23, 2008 Author Share Posted February 23, 2008 Thanks jazz. I mean require_once (db connect)...doesn't that tell me something? What is it doing when I call the DB connect script? Quote Link to comment https://forums.phpfreaks.com/topic/92625-mysql-connection-script/#findComment-474779 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.