SUNIL16 Posted October 23, 2008 Share Posted October 23, 2008 Hi Friends, Can u please tell me what is the below warning. till today my code is working fine. from yesterday i am getting this warning. Warning: mysql_connect() [function.mysql-connect]: Too many connections in C:\Domains\theinterviewsuccess.com\wwwroot\connect.php on line 2 could not open:Too many connections Link to comment https://forums.phpfreaks.com/topic/129763-can-u-please-tell-what-is-this-error/ Share on other sites More sharing options...
GKWelding Posted October 23, 2008 Share Posted October 23, 2008 You need to add mysql_close($conn) to the end of all your MySQL queries, especially if you're using mysql_pconnect. You've maxed out you db connections and no more are being freed up. Link to comment https://forums.phpfreaks.com/topic/129763-can-u-please-tell-what-is-this-error/#findComment-672722 Share on other sites More sharing options...
revraz Posted October 23, 2008 Share Posted October 23, 2008 Or talk to your host about allowing more connections to your DB. Link to comment https://forums.phpfreaks.com/topic/129763-can-u-please-tell-what-is-this-error/#findComment-672733 Share on other sites More sharing options...
SUNIL16 Posted October 23, 2008 Author Share Posted October 23, 2008 Hi Gkwelding can u please tell me You've maxed out you db connections and no more are being freed up. What it mean? i didn't get my hosting provider providing 8gb space and i can have 3 databases. Link to comment https://forums.phpfreaks.com/topic/129763-can-u-please-tell-what-is-this-error/#findComment-672787 Share on other sites More sharing options...
dropfaith Posted October 23, 2008 Share Posted October 23, 2008 space and databases arent really this error how many times are you connecting to the databases from this page without closing them with mysql_close($conn) Link to comment https://forums.phpfreaks.com/topic/129763-can-u-please-tell-what-is-this-error/#findComment-672790 Share on other sites More sharing options...
GKWelding Posted October 23, 2008 Share Posted October 23, 2008 Every time you query the database you open a connection to it, the max number of connections the database can handle is a configurable variable. Now, if you're using mysql_pconnect, or if you have a lot of users, then this maximum number of connections can be passed and you will get the error you're describing. To help with this situation you need to include the mysql_close function after every mysql_query. Or do as revraz said... Link to comment https://forums.phpfreaks.com/topic/129763-can-u-please-tell-what-is-this-error/#findComment-672797 Share on other sites More sharing options...
SUNIL16 Posted October 23, 2008 Author Share Posted October 23, 2008 Hi Friends, Thanks for your reply, Below is how i am using the code to connect 1] <?php $servername='my server name'; $dbusername='my username'; $dbpassword='password'; $dbname='mysite'; connecttodb($servername,$dbname,$dbusername,$dbpassword); function connecttodb($servername,$dbname,$dbuser,$dbpassword) { global $link; $link=mysql_connect ("$servername","$dbuser","$dbpassword"); if(!$link){die("Could not connect to MySQL");} mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error()); mysql_close($con);(can i close like this?) }?> 2] <?php $con=mysql_connect("my server name","username","password"); if(!$con) { die('could not open:'.mysql_error()); } mysql_close($con); ?> In the above two which one is correct way? I am new to php doing some projects Link to comment https://forums.phpfreaks.com/topic/129763-can-u-please-tell-what-is-this-error/#findComment-672861 Share on other sites More sharing options...
SUNIL16 Posted October 23, 2008 Author Share Posted October 23, 2008 or Please suggest me how can i use connect and close function globally. or any better way i can make. Link to comment https://forums.phpfreaks.com/topic/129763-can-u-please-tell-what-is-this-error/#findComment-672863 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.