0

I get the errors only on a live hosting account(hostinger). It works perfectly fine on my local(XAMPP) server. Additionally, on the live hosting server, the error only comes up if I am executing multiple checks that calls their respective PDO statements.

Heres my code:

if(check if user exists){
   if(submitted status different from status in DB){
   call PDO function to update status and enter into log file
   }

   if(submitted role different from role in DB){
   call PDO function to update role and enter into log file
   }

   if(submitted class different from class in DB){
   call PDO function to update class and enter into log file
   }
 }else{
       redirect()
    }

The three "if statements" only check if the submitted value is different from the value present in the DB so I can update only if the submitted values are different from the respective one in the DB. Also the status, role, and class do not depend on one another.

PDO function:

  Each PDO function has a query like 
  "INSERT INTO log where....;
   UPDATE users where...."

I get the error if two or more conditions pass. If only one condition pass e.g only the status needs to be updated then I don't get any error.

Additionally, even if two or more conditions pass(eg. the status and role need to be updated) and I do get the error, the changes are somehow successfully reflected in the DB.

As I have mentioned before, everything works perfectly fine on XAMPP.

The ERROR on the hosting site:

 Warning: Packets out of order. Expected 2 received 3. Packet size=48 
 in..... line 39

 Warning: Database::query(): MySQL server has gone away in..... line 39

 Warning: Database::query(): Error reading result set's header 
 in.....line39 

 Fatal error: Uncaught PDOException: SQLSTATE[HY000]General error: 2006 
 MySQL server has gone awayin.......<--SOME VERY LONG TEXTS-->

I would really appreciate it if someone could shed some light on why I am getting this error.

I apologize if this is a dumb question!

1 Answers1

1

Never encountered this error before, but Ive used Hostinger and other free hosting websites, and they usually give pretty bad service for free accounts

From googling the error, Ive found this stackoverflow answer : MySQL error 2006: mysql server has gone away and based on u saying the queries work on localhost, the problem might be a "very low default setting of max_allowed_packet" by Hostinger which causes your parallel queries to crash

I recommend trying out "alwaysdata.com", best free host i found

Benoit F
  • 479
  • 2
  • 10
  • 1
    thanks a lot. I just changed my host to "alwaysdata.com", now everything's fine, no errors. I was also searching for a free host to practice node.js and "alwaysdata.com" has that too. So, technically you solved two problems of mine... cheers!! – Tumtin Eliezer Oct 18 '19 at 10:58