Most languages have the option to use 'persistent' connections - this is where a connection to a MySQL server is kept open, even after the script has finished executing. This can be useful to (usually marginally) speed up a script, as the next time the script is executed the MySQL server connection attempt is quickly handed the existing connection. The down side to this is that by holding the connection open, it uses up one of the available connection slots on the MySQL server and so could potentially block another connection attempt (the MySQL server does not have a LRU disconnection policy).
As for your "Too many connections" problem, it could be one of three things:
1) The server has too many open connections already. A MySQL server can only handle a specific number of open connections before refusing to allow any more, and this limit is shared amongst all users of the server. It's usually set quite high, although it's easily possible for someone to effectively DoS a MySQL server by making lots of connections (but see below)
2) Your user account has a limited number of connections allowed per hour - any further connections within that hour would be rejected. This is set on a per-user basis.
3) Your user accounts has a limited number of allowable open connections - any further connections would be rejected. This is set on a per-user basis.
It's always important to read the error message you get returned on the connection attempt, as in most cases this will pinpoint the exact reason for failure.
If your account has a maximum number of connections limit (scenario #3), the error would be:
ERROR 1226 (42000): User 'mysqldba' has exceeded the 'max_user_connections' resource (current value: 1)
Where 'mysqldba' would be your username, and the 'current value' is the maximum number of open connections allowed from this user.
If you account has a maximum number of connections per hour limit (scenario #2), the error would be:
ERROR 1226 (42000): User 'mysqldba' has exceeded the 'max_connections_per_hour' resource (current value: 1)
Where, once again, 'mysqldba' would be your username, and the 'current value' is the maximum number of connections per hour allowed for this user.
The error message you got (code 1040) indicates that the entire MySQL server has run out of connection slots - this is the DoS scenario I mention above.
What can you do about it? From what you've said, you don't have superuser privileges on this server, so nothing, apart from complain to the SysAdmin responsible for that server. They might increase the maximum number of connections allowed, which could solve the problem short-term, but if someone else using the server is creating a stupid number of database connections the slots would just fill up again. What they probably should do is to also enforce a per-user maximum open connection limit as well - this would stop the heavy users clogging up the server. In a shared-server situation like yours, this would make the most sense - 'power users' would/should have their own server, or could/should pay to increase their maximum open connections.