"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/