Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [php]problem z funkcją w firefoxie
Forum PHP.pl > Forum > Przedszkole
puz219
Witam.

mam pewien problem z Firefoksem.

Napisałem sobie funkcję, która zamienia mi polskie znaki na utf.
I teraz mam formularz i chciałbym, żeby dane z jednego pola były "przepuszczane" przez tą, funkcję, a następnie po zmianie znaków dodawane do bazy mysql.

I teraz tak, napisałem cały skrypt, wszystko ładnie pięknie.... tylko, że w Firefoksie nie działa.
Znaczy działa częściowo - dodaje wszystko, dopóki nie będzie polskiego znaku.

PS. w Internet Explorerze (mam wersję 7), wszystko działa OK.

Oto funkcja
  1. <?php
  2. function znaki($tekst) {
  3. $tekst = str_replace("Ą", "Ą", $tekst);
  4. $tekst = str_replace("ą", "ą", $tekst);
  5. $tekst = str_replace("Ć", "Ć", $tekst);
  6. $tekst = str_replace("ć", "ć", $tekst);
  7. $tekst = str_replace("Ę", "Ę", $tekst);
  8. $tekst = str_replace("ę", "ę", $tekst);
  9. $tekst = str_replace("Ł", "Ł", $tekst);
  10. $tekst = str_replace("ł", "ł", $tekst);
  11. $tekst = str_replace("Ń", "Ń", $tekst);
  12. $tekst = str_replace("ń", "ń", $tekst);
  13. $tekst = str_replace("Ó", "Ó", $tekst);
  14. $tekst = str_replace("ó", "ó", $tekst);
  15. $tekst = str_replace("Ś", "Ś", $tekst);
  16. $tekst = str_replace("ś", "ś", $tekst);
  17. $tekst = str_replace("Ź", "Ź", $tekst);
  18. $tekst = str_replace("ź", "ź", $tekst);
  19. $tekst = str_replace("Ż", "Ż", $tekst);
  20. $tekst = str_replace("ż", "ż", $tekst);
  21. $tekst = str_replace("Á", "Á", $tekst);
  22. $tekst = str_replace("Â", "Â", $tekst);
  23. $tekst = str_replace("Ä", "Ä", $tekst);
  24. $tekst = str_replace("Ç", "Ç", $tekst);
  25. $tekst = str_replace("É", "É", $tekst);
  26. $tekst = str_replace("Ë", "Ë", $tekst);
  27. $tekst = str_replace("Í", "Í", $tekst);
  28. $tekst = str_replace("Î", "Î", $tekst);
  29. $tekst = str_replace("Ô", "Ô", $tekst);
  30. $tekst = str_replace("Ö", "Ö", $tekst);
  31. $tekst = str_replace("Ú", "Ú", $tekst);
  32. $tekst = str_replace("Ü", "Ü", $tekst);
  33. $tekst = str_replace("Ý", "Ý", $tekst);
  34. $tekst = str_replace("ß", "ß", $tekst);
  35. $tekst = str_replace("á", "á", $tekst);
  36. $tekst = str_replace("â", "â", $tekst);
  37. $tekst = str_replace("ä", "ä", $tekst);
  38. $tekst = str_replace("ç", "ç", $tekst);
  39. $tekst = str_replace("é", "é", $tekst);
  40. $tekst = str_replace("ë", "ë", $tekst);
  41. $tekst = str_replace("í", "í", $tekst);
  42. $tekst = str_replace("î", "î", $tekst);
  43. $tekst = str_replace("ô", "ô", $tekst);
  44. $tekst = str_replace("ö", "ö", $tekst);
  45. $tekst = str_replace("ú", "ú", $tekst);
  46. $tekst = str_replace("ü", "ü", $tekst);
  47. $tekst = str_replace("ý", "ý", $tekst);
  48. $tekst = str_replace("Ă", "Ă", $tekst);
  49. $tekst = str_replace("ă", "ă", $tekst);
  50. $tekst = str_replace("Č", "Č", $tekst);
  51. $tekst = str_replace("č", "č", $tekst);
  52. $tekst = str_replace("Ď", "Ď", $tekst);
  53. $tekst = str_replace("ď", "ď", $tekst);
  54. $tekst = str_replace("Đ", "Đ", $tekst);
  55. $tekst = str_replace("đ", "đ", $tekst);
  56. $tekst = str_replace("Ě", "Ě", $tekst);
  57. $tekst = str_replace("ě", "ě", $tekst);
  58. $tekst = str_replace("Ĺ", "Ĺ", $tekst);
  59. $tekst = str_replace("ĺ", "ĺ", $tekst);
  60. $tekst = str_replace("Ľ", "Ľ", $tekst);
  61. $tekst = str_replace("ľ", "ľ", $tekst);
  62. $tekst = str_replace("Ň", "Ň", $tekst);
  63. $tekst = str_replace("ň", "ň", $tekst);
  64. $tekst = str_replace("Ŕ", "Ŕ", $tekst);
  65. $tekst = str_replace("ŕ", "ŕ", $tekst);
  66. $tekst = str_replace("Ř", "Ř", $tekst);
  67. $tekst = str_replace("ř", "ř", $tekst);
  68. $tekst = str_replace("Ş", "Ş", $tekst);
  69. $tekst = str_replace("ş", "ş", $tekst);
  70. $tekst = str_replace("Š", "Š", $tekst);
  71. $tekst = str_replace("š", "š", $tekst);
  72. $tekst = str_replace("Ţ", "Ţ", $tekst);
  73. $tekst = str_replace("ţ", "ţ", $tekst);
  74. $tekst = str_replace("Ť", "Ť", $tekst);
  75. $tekst = str_replace("ť", "ť", $tekst);
  76. $tekst = str_replace("Ů", "Ů", $tekst);
  77. $tekst = str_replace("ů", "ů", $tekst);
  78. $tekst = str_replace("Ű", "Ű", $tekst);
  79. $tekst = str_replace("ű", "ű", $tekst);
  80. $tekst = str_replace("Ž", "Ž", $tekst);
  81. $tekst = str_replace("ž", "ž", $tekst);
  82. return $tekst;
  83. }
  84. ?>


A to kod dodający wartości z formularza do bazy danych:
  1. <?php
  2. $data_pozyczenia=$_POST["pozycz_data"];
  3. $pozycz_komu=$_POST["pozycz_komu"];
  4. $pozycz_osobie=znaki("$pozycz_komu");
  5. $query = "UPDATE filmy SET pozycz='1' WHERE filmID='$id'";
  6. mysql_query($query);
  7. $query = "UPDATE filmy SET pozycz_data='$data_pozyczenia' WHERE filmID='$id'";
  8. mysql_query($query);
  9. $query = "UPDATE filmy SET pozycz_komu='$pozycz_osobie' WHERE filmID='$id'";
  10. mysql_query($query);
  11. echo "&nbsp;&nbsp;<b>Operacja zakończona powodzeniem.</b><br>&nbsp;&nbsp;Pożyczono osobie: <b>".$pozycz_osobie;
  12. ?>


czy wie ktoś dlaczego tak się dzieje?questionmark.gif
i jak rozwiązać ten problem??
b_chmura
hmm przy wysyłaniu formularza polskie znaki automatycznie zamieniają sie na ich odpowiedniki w odpowiednim kodowaniu (takie jakie masz ustawione w <head>

prawdopodobnie funkcja odbiera już te "przekształcone" i nie ma co zmieniać.


PS: mam nadzieje że to forum pozamieniało Twoje odpowiedniki na normalne znaki


pozdrawiam
Chmura
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.