And the issue is that when I do log in, sometimes it tells me this error from the infinityfree database, but I don’t understand it, may I please know what does that mean and how to fix it?
On XAMPP there are not such issues. and the variable is 151 for max user connections and it is 200 on mine, so it’s way enough
The space given by infinity free is way enough, the variable max users is 200 on infinity free but for 151 on localhost it works so I think the issue is from somewhere else
and those 2 ones "Warning: PDO::prepare(): SQLSTATE[00000]: No error: PDO constructor was not called in /home/vol1_8/epizy.com/epiz_33369697/htdocs/classes/PostManager.class.php on line 30
Fatal error: Uncaught Error: Call to a member function execute() on null in /home/vol1_8/epizy.com/epiz_33369697/htdocs/classes/PostManager.class.php:31 Stack trace: #0 /home/vol1_8/epizy.com/epiz_33369697/htdocs/index_logged.php(107): PostManager->listPost() #1 {main} thrown in /home/vol1_8/epizy.com/epiz_33369697/htdocs/classes/PostManager.class.php on line 31"
The limit for max_user_connections on InfinityFree is only 4. This should be plenty for most websites, assuming your code only opens one database connection per request, and closes them when done.
I took a quick look at your code, and the general setup seems to be put quite well together, and you already have a single database connection being passed around, so that’s good!
In the database setup code, you do appear to have one particular option enabled that’s causing all of your problems: persistent MySQL connections.
This option doesn’t work well on our hosting, and may not work at all. In very specific server setups (if you have your own server with PHP-FPM for example), it can work, but on a shared server that’s set up the way we’ve set up our hosting, enabling Persistent Connections just results in a large number of connections that are open simultaneously but cannot be used by your application.
Here is another topic from some time ago where someone else had a similar problem with persistent connections:
For you, the solution is much simpler though, no need to refactor your code. All you need to do is disable MySQL Persistent Connections and you shouldn’t ever see this error again.