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!