Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [MySQL][PHP]Błąd podczas próby wrzucenia Jsona do bazy, jw
miras
post 5.12.2017, 15:49:31
Post #1





Grupa: Zarejestrowani
Postów: 1 004
Pomógł: 9
Dołączył: 18.01.2011
Skąd: Siedlce

Ostrzeżenie: (30%)
XX---


Witam, próbuję wrzucić do bazy jeden większy json, który pobieram przez file_get_contents, mam następujący błąd:

  1. Uncaught PDOException: 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 's Fire","color":"eb4b4b"},{"type":"html","value":"or an Exceedingly Rare Special' at line



Pole do którego chcę wrzucić json ma typ text.


  1. public function updateSteamInv($userId, $inv) {
  2. if ($inv && $userId) {
  3. if ($this->checkSteamInv($userId)) {
  4. $this->update = $this->pdo->exec("UPDATE `flip_steam_inventory` SET `inventory` = '{$inv}' WHERE `user_id` = '{$userId}'");
  5. } else {
  6. $this->insert = $this->pdo->exec('INSERT INTO `flip_steam_inventory` (
  7. `inventory`, `user_id`) VALUES(
  8. \'' . $inv . '\',
  9. \'' . $userId . '\')');
  10.  
  11. }
  12.  
  13. return true;
  14. }
  15.  
  16. return false;
  17. }


Ma ktoś pomysł o co może chodzić?

Dzięki z góry!

Ten post edytował miras 5.12.2017, 15:52:21


--------------------
Go to the top of the page
+Quote Post
nospor
post 5.12.2017, 16:02:40
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Tyle czasu na forum i o ESCAPOWANIU danych nie slyszal?

Poza tym skoro uzywasz PDO to zainteresuj sie BINDowaniem a rozwiaze to twoj problem nawet lepiej jak escapowanie


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 17.06.2025 - 16:14