php - Error Message "MySQL server has gone away" when running an UPDATE query -



php - Error Message "MySQL server has gone away" when running an UPDATE query -

i run php file on cron job runs every minute, loop lasts 60 seconds. before loop starts, connect database mysqli. begin loop. first query gets list of users, query done on each list item first query. after updates on items have been done, outer loop sleeps 3 seconds before repeating.

the problem inner loop's query returns error "mysql server has gone away". started few days ago, after working fine weeks, , there has been no changes code. if re-create exact query gives me error, go phpmyadmin , paste in, updates no error.

the outer loop's query works every loop.

$mysqli = new mysqli($sql_data["domain"], $sql_data["user"], $sql_data["password"], $sql_data["database"]); $start_time = time(); while((time() - $start_time) < 60) { $stream_list = $mysqli->query("select * {$sql_data[table]} -- blah blah..."); $number_of_results = $stream_list->num_rows; // operates on each result sql phone call for($i = 1; $i <= $number_of_results; $i++) { //some if statements , switches // query returns error "mysql server has gone away" $mysqli->query("update {$sql_data[table]} set online=1, lastupdate = current_timestamp(), displayname = '$displayname' username='".$row["username"]."'"); }// for($i = 1; $i <= $number_of_results; $i++) }// while((time() - $start_time) < 60)

information databse:

server: localhost via unix socket

server type: mysql

server version: 5.5.32-cll-lve - mysql community server (gpl)

i not know if there update or changes recently, pay hosting web hosting company.

"server has gone away" error mysql returns when client has been disconnected server. happens in case when net connection not stable

otherwise seek increment timeout:

ini_set('mysql.connect_timeout', 300); ini_set('default_socket_timeout', 300);

php mysqli

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -