Re: TOO MANY CONNECTIONS!!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You can also do something like this:

if ($db_link = mysql_pconnect($host, $user, $pass)) {
    if (mysql_select_db($db,$db_link)) { return $db_link; }
    else die("MySQL Error: Cannot select {$db} database using {$user}@{$host}: ".mysql_error());
} else die("MySQL Error: Cannot connect to {$db}: ".mysql_error());

make $db_link global (if you use this in a function) then you can know that
you are connected if your script is still running.

If you make two connections, just make db_link something different for the
other connection, and do this:

$x = mysql_query("Select * from users",$db_link);

That will force PHP to use the $db_link specified instead of the "last
opened" connection.

Peter

On Fri, 25 Oct 2002, dr. Agon wrote:

> Helo,
>
> why you don't make some kind of "db_connect.php" which will make "mysql_pconnect()" and include it in top of your first script? You then will be able use mysql query in everyone of your page. You can also make $mysql_is_connected=true; there and check that variable in other scrips if need to be sure that this file was already included.
>
> --
> Regards, A.K.
>
> "Georgie Casey" <webmaster@filmfind.tv> wrote in message 20021024201835.36082.qmail@pb1.pair.com">news:20021024201835.36082.qmail@pb1.pair.com...
> > Yeah, sometimes I open and close 2 or 3 permanent connections in one page. I
> > knida have to as each page is made up of a few different include files, and
> > if I dont do seperate connections, it mightnt work.
> >
> > I'll recode my site to cache everything except search pages, or can I even
> > cache these as well??
> > "Duncan Hill" <dhill@cricalix.net> wrote in message
> > 20021023222841.GD30375@bajan.cricalix.net">news:20021023222841.GD30375@bajan.cricalix.net...
> > > On Wed, Oct 23, 2002 at 10:18:07PM +0100, Georgie Casey wrote:
> > > > Im getting a too many connections error in my PHP pages at
> > > > http://www.free-ringtones.tv. I presume this is from the MySQL server,
> > and I
> > > > know I access the database a lot for each page. So whats the solution to
> > >
> > > MySQL has a default of either 50 or 100 concurrent connections.  Exceed it
> > > and you'll get that error.  That parameter is configurable - if you run
> > the
> > > MySQL daemon itself.  If you use shared hosting, you may not be able to
> > > tweak it.
> > >
> > > Do the pages -need- to be totally dynamic, or can you use the caching
> > system
> > > you mentioned?  If so, then wrap code that stats an HTML page for the
> > time,
> > > and if it's too old, update it.  Be sure to use file locking so you don't
> > > clobber yourself.
> > >
> > > Moreover, do you open one connection and re-use it in a page, or do you do
> > > multiple opens and closes?
> >
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>

---------------------------------------------------------------------------
Peter Beckman            Systems Engineer, Fairfax Cable Access Corporation
beckman@purplecow.com                             http://www.purplecow.com/
---------------------------------------------------------------------------


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux