Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Uniwersalna funkcja do html decode
trifek
post
Post #1





Grupa: Zarejestrowani
Postów: 340
Pomógł: 0
Dołączył: 28.09.2015

Ostrzeżenie: (0%)
-----


Witam.
Mam tablice:

  1. (
  2. [save] => 1
  3. [title] => Monika Krzysiowa
  4. [contactUser] => Array
  5. (
  6. [0] => 29
  7. [1] => 11
  8. [2] => 17
  9. )
  10.  
  11. [email] => kontakt@mail.com
  12. [phone] => 12345678
  13. [description] => opis
  14. 1
  15. 2
  16. 3
  17. 4
  18. [enable] => 1
  19. )



lub



  1. (
  2. [save] => 1
  3. [title] => Monika Krzysiowa
  4. [email] => kontakt@gmail.com
  5. [phone] => 12345678
  6. [description] => opis
  7. 1
  8. 2
  9. 3
  10. 4
  11. [enable] => 1
  12. )



i taką funkcję w php:
  1. public function secureSave(array $string): array
  2. {
  3. foreach ($string as $key => $value) {
  4. $string[$key] = htmlspecialchars_decode($value, ENT_COMPAT);
  5. }
  6. return $string;
  7. }



Powyższa funkcja pracuje poprawnie dla 2 tablicy. W 1 mam problem i daje wynik:
  1. (
  2. [save] => 1
  3. [title] => Monika Krzysiowa
  4. [contactUser] =>
  5. [email] => kontakt@gmaail.com
  6. [phone] => 123456788
  7. [description] => opis
  8. 1
  9. 2
  10. 3
  11. 4
  12. [enable] => 1
  13. )


[contactUser] - problemem jest pusta wartość.

Jak naprawić powyższą funkcję tak żeby była uniwersalna?

Mam różne tablice, nazwy mogą być różne
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
trifek
post
Post #2





Grupa: Zarejestrowani
Postów: 340
Pomógł: 0
Dołączył: 28.09.2015

Ostrzeżenie: (0%)
-----


Przepraszam bardzo.
  1. array(2) {
  2. [0]=>
  3. string(9) ":username"
  4. [1]=>
  5. string(17) "admindzLHFu@pl.pl"
  6. }
  7. array(2) {
  8. [0]=>
  9. string(5) ":enum"
  10. [1]=>
  11. string(1) "4"
  12. }
  13. array(2) {
  14. [0]=>
  15. string(9) ":category"
  16. [1]=>
  17. string(1) "1"
  18. }
  19. array(2) {
  20. [0]=>
  21. string(9) ":username"
  22. [1]=>
  23. string(17) "admindzLHFu@pl.pl"
  24. }
  25. array(2) {
  26. [0]=>
  27. string(5) ":enum"
  28. [1]=>
  29. string(1) "4"
  30. }
  31. array(2) {
  32. [0]=>
  33. string(9) ":category"
  34. [1]=>
  35. string(1) "1"
  36. }
  37. array(2) {
  38. [0]=>
  39. string(9) ":username"
  40. [1]=>
  41. string(17) "admindzLHFu@pl.pl"
  42. }
  43. array(2) {
  44. [0]=>
  45. string(5) ":enum"
  46. [1]=>
  47. string(1) "4"
  48. }
  49. array(2) {
  50. [0]=>
  51. string(9) ":category"
  52. [1]=>
  53. string(1) "1"
  54. }
  55. array(2) {
  56. [0]=>
  57. string(7) ":enable"
  58. [1]=>
  59. string(1) "1"
  60. }
  61. array(2) {
  62. [0]=>
  63. string(7) ":number"
  64. [1]=>
  65. string(0) ""
  66. }
  67. array(2) {
  68. [0]=>
  69. string(12) ":description"
  70. [1]=>
  71. string(54) "'';fwefewfpew'f'wef'wefew.''fewvdsniu*&&^&^@^7ef125e2'"
  72. }
  73. array(2) {
  74. [0]=>
  75. string(21) ":visible_on_the_front"
  76. [1]=>
  77. string(0) ""
  78. }
  79. array(2) {
  80. [0]=>
  81. string(5) ":date"
  82. [1]=>
  83. string(10) "2019-02-27"
  84. }
  85. array(2) {
  86. [0]=>
  87. string(17) ":id_category_page"
  88. [1]=>
  89. string(2) "67"
  90. }
  91. array(2) {
  92. [0]=>
  93. string(22) ":visible_on_the_front2"
  94. [1]=>
  95. string(0) ""
  96. }
  97. array(2) {
  98. [0]=>
  99. string(9) ":title_pl"
  100. [1]=>
  101. string(54) "'';fwefewfpew'f'wef'wefew.''fewvdsniu*&&^&^@^7ef125e2'"
  102. }
  103. array(2) {
  104. [0]=>
  105. string(15) ":description_pl"
  106. [1]=>
  107. string(54) "'';fwefewfpew'f'wef'wefew.''fewvdsniu*&&^&^@^7ef125e2'"
  108. }
  109. array(2) {
  110. [0]=>
  111. string(12) ":keywords_pl"
  112. [1]=>
  113. string(54) "'';fwefewfpew'f'wef'wefew.''fewvdsniu*&&^&^@^7ef125e2'"
  114. }
  115.  
  116.  
  117. Fatal error: 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 MariaDB server version for the right syntax to use near ') VALUES ('', '67', '', '2019-02-27', '\'\';fwefewfpew\'f\'wef\'wefew.\'\'fewvds' at line 1 in /Applications/XAMPP/xamppfiles/htdocs/um_rumia/apps/core/utilities/DbClass.php:79
  118. Stack trace:
  119. #0 /Applications/XAMPP/xamppfiles/htdocs/um/apps/core/utilities/DbClass.php(79): PDOStatement->execute()
  120. #1 /Applications/XAMPP/xamppfiles/htdocs/um/apps/core/utilities/DbClass.php(105): Core\Utilities\Db->Init('INSERT INTO psG...', Array)
  121. #2 /Applications/XAMPP/xamppfiles/htdocs/um/apps/backend/models/GalleryModel.php(234): Core\Utilities\Db->query('INSERT INTO psG...', Array)
  122. #3 /Applications/XAMPP/xamppfiles/htdocs/um/apps/backend/controllers/GalleryList.php(149): Backend\Models\GalleryModel->saveDataFromForm(Array, 3)
  123. #4 [internal function]: Backend\Controllers\GalleryListAdminContro in /Applications/XAMPP/xamppfiles/htdocs/um/apps/core/utilities/DbClass.php on line 79

Go to the top of the page
+Quote Post

Posty w temacie
- trifek   [PHP]Uniwersalna funkcja do html decode   27.02.2019, 09:43:16
- - nospor   W momemecie gdy wartoscia jest kolejna tablica, to...   27.02.2019, 10:00:33
- - trifek   Czyli coś takiego: [PHP] pobierz, plaintext $stri...   27.02.2019, 10:14:15
- - nospor   Napisz ten kod jeszcze raz bo nie ma prawa sie w o...   27.02.2019, 10:25:16
- - trifek   [PHP] pobierz, plaintext public function secureSav...   27.02.2019, 10:33:31
- - nospor   CytatW jaki sposób sugerujesz żeby kodować html pr...   27.02.2019, 10:36:55
- - trifek   Hmmmm.... tylko jak nie dodaję tego "zabezpie...   27.02.2019, 10:42:39
- - nospor   Jak dla mnie to ta cala twoja klasa jest do przepi...   27.02.2019, 10:46:55
- - trifek   jak debuguję tutaj: [PHP] pobierz, plaintext $this...   27.02.2019, 12:14:38
- - nospor   Jak sam widzisz twoje zapytanie zawiera tekst ktor...   27.02.2019, 12:17:35
- - trifek   [PHP] pobierz, plaintext $queryValue["ena...   27.02.2019, 13:21:06
- - nospor   pokaz co zwraca: [PHP] pobierz, plaintext ...   27.02.2019, 13:26:28
- - trifek   [PHP] pobierz, plaintext array(2) { ...   27.02.2019, 13:31:24
- - nospor   Kurcze, jako przyklad podales mi zapytanie z INSER...   27.02.2019, 13:45:00
- - trifek   Przepraszam bardzo. [PHP] pobierz, plaintext array...   27.02.2019, 13:53:26
- - nospor   No i poprosze jeszcze jak to wywolujesz z tym zapy...   27.02.2019, 14:20:00
- - trifek   Selecty tak wywołuję: [PHP] pobierz, plaintext p...   27.02.2019, 22:17:52
- - nospor   $searchQuery .= " and ($searchNames...   28.02.2019, 09:48:45


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

 



RSS Aktualny czas: 12.10.2025 - 13:43