The most common reason behind the “MySQL server has gone away” error is your MySQL queries timing out.
That can happen if you use heavy or very long MySQL queries. To solve it, try adding the mysql_reconnect command before each query.
If the above solution doesn't help, we recommend you refer for help to websites and developer community forums like GitHub, Stack Overflow, or Fiverr, where thousands of web development professionals share their knowledge 📚