mysql maximum connections help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ppc
Forum Newbie
Posts: 14
Joined: Sat May 27, 2006 9:59 pm

mysql maximum connections help

Post by ppc »

My hosting provider only allows for 50 simultanious connections to a sql database at once and they said they wont change it. Does anyone know of a way that some sort of a script or something would check to make sure that the server can accept there connection and if not would hold them in a queue until a "spot" is avaiable to them to connect. This problem would be major for a vbulletin forum. Or if anyone has any other sugesstions that would be greatly appreciated.

Thanks.

PPC
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

You might be able to do something like this:

Code: Select all

function databaseconnect(){
// Connection Stuff 
   header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    // Data passata
   header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
                                                        // sempre modificato
   header("Cache-Control: no-store, no-cache, must-revalidate");  // HTTP/1.1
   header("Cache-Control: post-check=0, pre-check=0", false);
   header("Pragma: no-cache");                          // HTTP/1.0
   error_reporting(E_ALL);
   $host = 'localhost';
   $dbuser = '';
   $dbpass = '';
   $dbname = '';
   $table = '';
$db_connect = @mysql_connect($host,$dbuser,$dbpass);
   $db = mysql_select_db($dbname);
   if(!$db_connect)
   {
       databaseconnect();
   }
}
// Call to connect
databaseconnect();
This would try to connect to the database, and if it fails it would try again, until its available, it might make your code slower, but its something worth a shot for now
www.freemysql.net
Forum Newbie
Posts: 2
Joined: Thu Jun 15, 2006 3:35 am

Post by www.freemysql.net »

I hope your not paying for it, they could up that setting just a tad. It’s only going to help - now if it happens all the time they need to find who is doing it and stop them.
Post Reply