By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,872 Members | 2,392 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,872 IT Pros & Developers. It's quick & easy.

mySQL connection limit

P: n/a
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
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Titus Cheung" <ti***@ieee.org> writes:
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?
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/
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.
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
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?


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/
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.