Connecting Tech Pros Worldwide Help | Site Map

mySQL connection limit

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 01:36 AM
Titus Cheung
Guest
 
Posts: n/a
Default mySQL connection limit

Hello,

Thought I read somewhere saying that there is a limit to how many
connections are available per mySQL account or something like that. Can
someone please clarify?

I wrote a PHP tool that uses a different PHP file whenever someone hit an
HTML form button (ie Submit). It turned out that each one of these PHP
files need to re-open the link to the mySQL database by the following
snippet or else that particular file won't work:

@ $link = mysql_connect("localhost", "myself", "");
if (!$link == 1)
echo "Connection to database failed.";

But I thought that PHP will use the already opened link from the previous
PHP file and as a result the above is not necessary. Is this true, or only
if it is within the same PHP file? And would having called the above code
snippet too many times cause mySQL to prevent user "myself" from connecting
again?

Thanks



  #2  
Old July 17th, 2005, 01:36 AM
Michael Fuhr
Guest
 
Posts: n/a
Default Re: mySQL connection limit

"Titus Cheung" <titus@ieee.org> writes:
[color=blue]
> Thought I read somewhere saying that there is a limit to how many
> connections are available per mySQL account or something like that. Can
> someone please clarify?[/color]

Both PHP and MySQL have configuration settings that can limit a
user's database connections. See the documentation:

http://www.php.net/mysql
http://www.mysql.com/documentation/
[color=blue]
> I wrote a PHP tool that uses a different PHP file whenever someone hit an
> HTML form button (ie Submit). It turned out that each one of these PHP
> files need to re-open the link to the mySQL database by the following
> snippet or else that particular file won't work:
>
> @ $link = mysql_connect("localhost", "myself", "");
> if (!$link == 1)
> echo "Connection to database failed.";
>
> But I thought that PHP will use the already opened link from the previous
> phP file and as a result the above is not necessary.[/color]

Without a call to mysql_connect() or mysql_pconnect(), how would
PHP know which database you want to connect to? How would PHP know
which "previous" file's database connection to re-use?

You might be thinking of persistent connections, where you can use
a previously-established connection by calling mysql_pconnect().

http://www.php.net/features.persistent-connections
http://www.php.net/mysql_pconnect
[color=blue]
> Is this true, or only if it is within the same PHP file? And
> would having called the above code snippet too many times cause
> mySQL to prevent user "myself" from connecting again?[/color]

It's possible that repeated connections would eventually fail --
you'll have to check your PHP and MySQL configurations to see what
the limits are.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.