| | |
Connecting to MySQL
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jan 2005
Posts: 2
Reputation:
Solved Threads: 0
Hi,
I am creating a database driven website - and I have the content stored in a mysql database at the moment. At the moment each page starts with the script:
$connect = mysql_connect('$host', '$username', '$password');
$select = mysql_select_db('$database', $connect);
This works fine, but if Iv been playing around with the site for too long, it comes back with an error that too many database connections are open.
I have a few questions:
1) Does the script above open a new connection each time it is executed?
2) If so how can I reuse a connection across pages?
3) If not how would I stop 'too many connections' from being opened?
Many Thanks
Steve
I am creating a database driven website - and I have the content stored in a mysql database at the moment. At the moment each page starts with the script:
$connect = mysql_connect('$host', '$username', '$password');
$select = mysql_select_db('$database', $connect);
This works fine, but if Iv been playing around with the site for too long, it comes back with an error that too many database connections are open.
I have a few questions:
1) Does the script above open a new connection each time it is executed?
2) If so how can I reuse a connection across pages?
3) If not how would I stop 'too many connections' from being opened?
Many Thanks
Steve
I have been "reading" MySQL manual yesterday...
1. -
2. MySQL allow 4000 (or 400??) simultaneous connections. After you close the database, it will take 3-4 minutes before the connection can be reuse.
3. You can use SSI to open the connection of a page and only close it when leaving the page. Alternatively, but I've never try before, you may use session to open (session start) and close (session end) the connection when someone visiting to and leaving the site, respectively.
1. -
2. MySQL allow 4000 (or 400??) simultaneous connections. After you close the database, it will take 3-4 minutes before the connection can be reuse.
3. You can use SSI to open the connection of a page and only close it when leaving the page. Alternatively, but I've never try before, you may use session to open (session start) and close (session end) the connection when someone visiting to and leaving the site, respectively.
![]() |
Similar Threads
- Connecting to a Remote Database(mySQL) on LAN (VB.NET)
- Error connecting to mysql (MySQL)
- Connecting to MySQL with PHP (MySQL)
- Need Help in Connecting MySQL Database to JTable (Java)
- Error connecting to MySql (VB.NET)
- having trouble in connecting mysql with php (PHP)
- Problems connecting to MySQL (IT Professionals' Lounge)
- Help connecting to mysql tables (JSP)
- connecting to mysql in linux (Java)
Other Threads in the MySQL Forum
- Previous Thread: Database connectioin error
- Next Thread: Ms Access Help Please
| Thread Tools | Search this Thread |
agplv3 alfresco amazon api aws bizspark breathalyzer changingprices cmg communityjournalism contentmanagement contractors copyright count court crm database design developer development distinct drupal dui ec2 email enterprise eudora facebook form foss gartner gnu government gpl greenit groklaw groupware hiring hyperic images innerjoins insert ip joebrockmeier join journalism keyword keywords kickfire laptop law legal license licensing linux maintenance managing mariadb matchingcolumns metron micromanage microsoft microsoftexchange mindtouch montywidenius mozilla multiple mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource oracle penelope php priceupdating query referencedesign reorderingcolumns resultset saas select sharepoint simpledb sourcecode spotify sql sugarcrm syntax techsupport thunderbird transparency virtualization





