$db->Query("SELECT * FROM db_video_users WHERE parts>'0' ORDER BY id DESC"); $tim = time(); while($datas = $db->FetchArray()){ $id = $datas["id"]; $db->Query("UPDATE db_video_users SET time_earn = '$tim', parts = parts-'1' WHERE id = '$id'"); } 
  • The result was not received, the connection is busy and cannot complete the next query. - Akina
  • I am trying to decipher what you said) The result is just received, but the cycle does not repeat - Vitaly Chilingirov
  • You have completed the first request (before the cycle). He returned the result. You raked it out of the connection by doing FetchArray. The connection is released and ready to go. Then we executed the second query (in a loop on the first turn). He returned the result. You are trying to execute the third query (on the second loop of the loop). However, the connection still contains the result of the second query. Therefore, the connection is unable to perform the third request - while the result of the second request is lost, and this is unacceptable. So add a fetch to the loop as well. - Akina
  • Thank you for the detailed answer. I am a beginner and do not quite understand how and where to add it .. - Vitaly Chilingirov

2 answers 2

 $db->Query("UPDATE db_video_users SET time_earn = UNIX_TIMESTAMP(), parts = parts-'1' WHERE parts>'0'") 

Please do not do anonymity.

    The problem is in the class that implements the Query() method. There is even a special list of rakes that beginner class writers are attacking to work with the database . Specifically, these are at number 8.

    Considering that in this class the rake at number 1 is blooming and smelling - SQL injection, then we must get rid of it immediately.

    If you wrote the class yourself, you need to rewrite it. I can help with this. If you took somewhere for the occasion, then we must abandon it, and take something normal. Best of all - clean PDO and learn to work with it first.