I’m trying to import the excel data to mysql database by PHP Ajax method. When the user upload an excel, the jQuery will fetch each row by loop and send it to PHP via ajax but there are about 500++ rows. Due to that, the PHP is running the query simultaneously and causing the database error already has more than 'max_user_connections' active connections. Some of the query are working but some not.
>Solution :
the jQuery will fetch each row by loop and send it to PHP via ajax
…this is a design flaw. If you try to generate 500 AJAX requests in a short space of time it’s inevitable, due to its asynchronous nature, that a lot of them will overlap and overload the server and database…but I think you’ve realised that already, from your description.
So you didn’t really ask a question, but are you just looking for alternative implementation options?
It would make more sense to either
- just upload the whole file as-is and let the server-side code process it.
Or
- If you must read it on the client-side, you should at least send all the rows in one AJAX request (e.g. as a JSON array or something).