Probably you have limited access of your hosting server resources. Your hosting provider is not allowed more mysqli connections and when your class tries to get a new connection then you have got this error because of already you have some running mysqli connections.
This is not a mysqli problem or not a programming problem. This is limited access problem of hosting server.
For solving this problem, you have to configure more connections on config file that is located on the hosting server. If you don't have server access then you have to ask the server support team of hosting server or another options you have, change for a hosting company that allowed you to more connections.
Another way for solving max_user_connections error is optimize your database table.
How to optimize database table and query for reducing max_user_connections error?
- First, Index your table field in mysql
- Second, In every select query, Remove `*` symbol and write fields name which you require.
- Third, Close all mysql_connection.
Other option for solving max_user_connections error:
- Go to phpMyAdmin
- Select your database
- Click on "Privileges"
You will find: Users having access to "databaseName"
- Now, select user name under existing database
- Click on "Edit privileges" under Action
You will find: Global privileges
- Now, you will see "MAX USER_CONNECTIONS" under Resource limits in right hand side
- Now, Increase all value as per your requirements or set all to ZERO for remove the limitation.