CMMDB Posted December 16, 2008 Posted December 16, 2008 Hey! So my Heliohost site is up and running smoothly, but not optimally. As visits increase, I've been getting errors regarding exceeding the number of allowed MySQL connections.So I looked up a snippet and adapted it to my needs. Question is, since I can't really see the amount of current MySQL connections in a way that I'm aware of, would this snippet theoretically do the job?Did I adapt it correctly? I include this wherever I need a db connection(Most every page) and call GetMyConnection(). (fatal_error() just dies with an image attached) <?php if (!isset($g_link)) { $g_link = false; } function GetMyConnection() { global $g_link; if( $g_link ) return $g_link; $g_link = @mysql_pconnect( 'localhost:3306', 'usr', 'pwd') or fatal_error("Could not connect to mysql server.<!--".mysql_error()."-->" ); @mysql_select_db('db', $g_link) or fatal_error("Could not select database.<!--".mysql_error()."-->"); return $g_link; } ?> Quote
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.