Error: User epiz_23862135 already has more than ‘max_user_connections’ active connections
Most of my scripts are showing this error, but I believe no other user is online as of now. Please help me out ASAP, the System is being tested with real data.
The homepage is actually ok, but after logging in to mysquavero.ga account, that error comes up. but few minutes ago, it was working properly. Please help me out!
I’ve read that, but it was working just a few hours ago. Am trying to put a destructor to the php scripts that are bringing that error to close connections
How so? You say “not working” but provide no detail… is the connection already closed? is the query not working?
Did you enable display_errors?
I assume you’re trying to run SQL queries through a home-grown php class function. In my past experience, I had trouble just running queries themselves.
If you need some help, do you mind elaborating a bit?
I have over 4 classes, php scripts that write up my page, they all fetch data from the database. This is their basic mark up
<?php
class className{
private $db_one;
private $db_two;
//Other Variables
public function __construct()
{
$this->db_one=mysqli_connect('a','b','c','d');
$this->db_two=mysqli_connect('a','b','c','e');
}
public function __destruct()
{
mysqli_close($this->db_one);
mysqli_close($this->db_two);
}
//Other methods that might be calling these db_variables
}
I wasnt doing this before, I’ve edited to this after coming across this error.
The issue you’re experiencing, as well as the code that’s generating it, is quite similar to a case from a month ago.
The issue is that with your code structured like this, every object instance creates it’s own database connection. And in the example, it even creates two connection for a single class! So if you instantiate, say, five different objects, this can result in 5 (10?) database connections for a single requests, which makes it very easy to hit the connection limit.
The right way to fix this is to only create one database connection per request and use that across all objects and classes. There are few different patterns you can use for this, but the Singleton Pattern (which I explained in that other post) is effective and simple to implement.
No. The solution is the exact opposite. Keep the connection open and then close it only when you are done making queries.
In free hosting, your database only gets one user, the epiz_xxxxxxxx account name you were assigned when you created the account.
Read what I wrote above in this post. You can’t add users, and yes we have a modified phpMyAdmin installation, so it will be different from your local server.
Of course! But what do you need an example of? We can try to help you to the best of our abilities, but that’s hard when we don’t know exactly what to help you with.
Again, you can’t add a user here. You have one, that’s enough, and that’s all you’ll get.
There is no one else accessing my site right now, why should it keep showing that error? Unless someone has connected to exhaust my user connection limit, could you please check that for me?