PHP: MySQL server is gone

I know this question has been asked many times, but I tried everything.

I have a PHP script that iterates through thousands of images, resizes if necessary, and then inserts it into the database.

I get this error message:

Warning: mysql_query () [function.mysql-query]: MySQL server went to C: \ Utilities \ server \ htdocs \ newGen \ index.php on line 105

Warning: mysql_query () [function.mysql-query]: result of reading an error, set the header to C: \ Utilities \ server \ htdocs \ newGen \ index.php on line 105

I use Xampplite, so some parts of php.ini are missing, others are used to solve the problem, because they do not use the light version.

I am sure that the problem is not in timeouts. While the script will run for several minutes, it skips the images that have already been processed, and therefore I quickly get an error message in about 10 seconds. Maybe this is due to the maximum size of the table? I can not find anything in my php.ini that controls this.

Any help is appreciated, I have been going this way for hours.

EDIT:

Here is the code at 105, this is a request:

// Add tNail and image to db mysql_query("INSERT INTO gallery values('','$hash','$thumbBlob','$imageBlob','$type','','0','0.0')"); // $q->execute(); print "Successfully processed $fileName<br>"; 

As you can see from the comments, I tried PDO with this and got the same error, out of stupidity, I thought returning to mysql_ commands would help.

If any help script complains about the same image every time, but each image will be only a few tens of kilobytes and no more than a couple of hundred.

+8
source share
4 answers

Check the value <<20 โ†’ in the my.cnf MySQL configuration file.

+25
source

This is because the PHP script took too much time to process everything that it was processing, and the time to wait for a connection to the server. You have several solutions:

  • Make sure the connection is still enabled and connect if necessary ( mysql_connect has built-in functions for this)
  • Use mysql_pconnect (but remember to close the connection at the end, because it will not be closed for you)
  • Increase script runtime to avoid timeout.
+1
source

you can use mysql_ping() to find out if the connection is connected again if you cannot try to reconnect or make an error message telling you how far the script went before the connection was lost.

+1
source

I also have this problem, how to solve

0
source

Source: https://habr.com/ru/post/920978/


All Articles