SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1,40), (,2,40), (,3,40), (,4,20), (2,14,10), (,14,10), (2,22,2),

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1,40), (,2,40), (,3,40), (,4,20), (2,14,10), (,14,10), (2,22,2),

      Message: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1,40), (,2,40), (,3,40), (,4,20), (2,14,10), (,14,10), (2,22,2), (2,23,2), (2,24' at line 1
      File: /includes/classes/Database.class.php
      Line: 242
      URL: domain-name.de/admin.php?page=statsupdate
      PHP-Version: 5.6.40
      PHP-API: fpm-fcgi
      MySQL-Cleint-Version: mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $
      2Moons Version: 1.7.git
      Debug Backtrace:
      #0 /includes/classes/Database.class.php(242): PDO->query('INSERT INTO uni...')
      #1 /includes/classes/class.statbuilder.php(169): Database->nativeQuery('INSERT INTO %%R...')
      #2 /includes/classes/class.statbuilder.php(159): statbuilder->SaveDataIntoDB('TRUNCATE TABLE ...')
      #3 /includes/classes/class.statbuilder.php(513): statbuilder->writeRecordData()
      #4 /includes/pages/adm/ShowStatUpdatePage.php(35): statbuilder->MakeStats()
      #5 /admin.php(273): ShowStatUpdatePage()
      #6 {main}

      does anyone have an idea what can cause the error?

      The post was edited 1 time, last by swerck ().

    • $SQL .= "INSERT INTO %%RECORDS%% (userID, elementID, level) VALUES ".implode(', ', $QueryData).";";

      you might have some users with empty userID, check your %%USERS%% (uni1_users) table

      Or for some reason you don't select userID and you need to check setRecords

      this->setRecords($PLANET['id_owner'], $Build, $PLANET[$resource[$Build]]);

      (you might have some planets with id_owner not present )

      to solve it

      open your db, and run this under your database, SELECT * FROM uni1_planets WHERE id_owner = ""; ( probably this is the issue )

      delete all columns if any appears,

      or check SELECT * FROM uni1_users WHERE id = ""; ( unlikely )

      delete the results
    • i have run both in the db, both were unsuccessful. i have no planets without id as well as users without id.

      then I saved the db and loaded an empty one, also there comes the same error. can it be that it is possibly somewhere in the code?
    • find this line under statbuilder

      private function setRecords($userID, $elementID, $amount)
      {
      $this->recordData[$elementID][$amount][] = $userID;
      }

      change it to

      private function setRecords($userID, $elementID, $amount)
      {
      if(!empty($userID)){
      $this->recordData[$elementID][$amount][] = $userID;
      }
      }

      it might work not sure
    • PHP Source Code: includes/classes/class.statbuilder.php

      1. private function writeRecordData()
      2. {
      3. $QueryData = array();
      4. foreach($this->recordData as $elementID => $elementArray) {
      5. krsort($elementArray, SORT_NUMERIC);
      6. $userWinner = reset($elementArray);
      7. $maxAmount = key($elementArray);
      8. $userWinner = array_unique($userWinner);
      9. if(count($userWinner) > 3)
      10. {
      11. $keys = array_rand($userWinner, 3);
      12. foreach($keys as $key)
      13. {
      14. if(isset($userWinner[$key]) && $userWinner[$key] != ''){
      15. $QueryData[] = "(".$userWinner[$key].",".$elementID.",".$maxAmount.")";
      16. }
      17. }
      18. }
      19. else
      20. {
      21. foreach($userWinner as $userID) {
      22. if(isset($userID) && $userID != ''){
      23. $QueryData[] = "(".$userID.",".$elementID.",".$maxAmount.")";
      24. }
      25. }
      26. }
      27. }
      28. if(!empty($QueryData)) {
      29. $SQL = "TRUNCATE TABLE %%RECORDS%%;";
      30. $SQL .= "INSERT INTO %%RECORDS%% (userID, elementID, level) VALUES ".implode(', ', $QueryData).";";
      31. $this->SaveDataIntoDB($SQL);
      32. }
      33. }
      Display All
      this could avoid the error, but it is only a temporary solution.
      it could cause that the records ar not processed properly.
      you have to find out why $userID is not set, since the other values are set i guess it might be related to the behavior of array_unique() in line 137