Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP]Problem z iconv
majestiq
post
Post #1





Grupa: Zarejestrowani
Postów: 235
Pomógł: 0
Dołączył: 26.10.2006

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


Mam taki kodzik:

  1. <?php
  2. $plik = fopen("pozdrowienia.txt", "w");
  3. flock($plik, 2);
  4. $_POST['pozd'] = Cenzura($_POST['pozd']);
  5. fwrite($plik, iconv_set_encoding('internal_encoding', 'UTF-8'($_POST['pozd']))." r\n");
  6. for($i=0; $i < $ile; $i++) fwrite($plik, ($tekst[$i]));
  7. flock($plik, 3);
  8. fclose($plik);
  9. setcookie ("sent", "sent", time()+60); //ustawia ciasto mowiace o tym, ze już wyslal pozdrowienia. 1=1 sekunda
  10. ?>


Chcę zmienić kodowanie za pomocą iconv, ale wywala mi taki błąd:

Parse error: syntax error, unexpected '(' in /home/mp4/ftp/pozdr.php

Próbowałem mieszać coś z nawiasami, ale bez efektów.
Może ktoś pomóc ?


--------------------
Free mp3 download.
Go to the top of the page
+Quote Post
l0ud
post
Post #2





Grupa: Zarejestrowani
Postów: 1 387
Pomógł: 273
Dołączył: 18.02.2008

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


tak na oko
Kod
'UTF-8'($_POST['pozd']))." \r\n");


Zjadłeś przecinek

Kod
'UTF-8',($_POST['pozd']))." \r\n");


--------------------
XMPP: l0ud@chrome.pl
Go to the top of the page
+Quote Post
majestiq
post
Post #3





Grupa: Zarejestrowani
Postów: 235
Pomógł: 0
Dołączył: 26.10.2006

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


Raczej chyba nie bo teraz mam coś takiego:

Warning: iconv_set_encoding() expects exactly 2 parameters, 3 given in /home/mp4/ftp/pozdr.php on line 54

Warning: Cannot modify header information - headers already sent by (output started at /home/mp4/ftp/pozdr.php:54) in /home/mp4/ftp/pozdr.php on line 58


Czyli jednak bez przecianka, ale co jest źle ?


--------------------
Free mp3 download.
Go to the top of the page
+Quote Post
comanderv
post
Post #4





Grupa: Zarejestrowani
Postów: 87
Pomógł: 1
Dołączył: 2.12.2008

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


"Warning: iconv_set_encoding() expects exactly 2 parameters, 3 given in /home/mp4/ftp/pozdr.php on line 54"

czyli masz jeden parametr w tej funkcji za duzo tongue.gif
Go to the top of the page
+Quote Post
majestiq
post
Post #5





Grupa: Zarejestrowani
Postów: 235
Pomógł: 0
Dołączył: 26.10.2006

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


No wiem, ale to dlatego, że zrobiłem tak jak zasugerował l0ud -> dodałem przecinek, i zostało to zinterpretowane jako dodatkowy parametr.
W wersji oryginalnej nie było przecinka, ale też nie działała :/
Chyba coś z nawiasami ?


--------------------
Free mp3 download.
Go to the top of the page
+Quote Post
comanderv
post
Post #6





Grupa: Zarejestrowani
Postów: 87
Pomógł: 1
Dołączył: 2.12.2008

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


  1. <?php
  2. fwrite($plik, ($tekst[$i]));
  3. ?>

moze o ten nawias chodzi z tablicy $tekst ?

Ten post edytował comanderv 20.04.2009, 17:58:02
Go to the top of the page
+Quote Post
majestiq
post
Post #7





Grupa: Zarejestrowani
Postów: 235
Pomógł: 0
Dołączył: 26.10.2006

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


Tamta linijka jest ok, błąd jest w tej:

  1. <?php
  2. fwrite($plik, iconv_set_encoding('internal_encoding', 'UTF-8'($_POST['pozd']))." r\n");
  3. ?>


--------------------
Free mp3 download.
Go to the top of the page
+Quote Post
comanderv
post
Post #8





Grupa: Zarejestrowani
Postów: 87
Pomógł: 1
Dołączył: 2.12.2008

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


Kod
fwrite($plik, iconv_set_encoding('internal_encoding', "UTF-8".($_POST['pozd']))." \r\n")

?
Go to the top of the page
+Quote Post
potreb
post
Post #9





Grupa: Zarejestrowani
Postów: 1 568
Pomógł: 192
Dołączył: 7.03.2005
Skąd: Warszawa

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


http://forum.php.pl/index.php?showtopic=96...nv_set_encoding

Jeżeli chcesz zmienić kodowanie dla tekstu to tylko iconv


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

Go to the top of the page
+Quote Post
l0ud
post
Post #10





Grupa: Zarejestrowani
Postów: 1 387
Pomógł: 273
Dołączył: 18.02.2008

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


Aaa, nie. Ten kod jest jednak bez sensu.
Zamiast iconv_set_encoding użyj funkcji iconv - tylko musisz znać kodowanie wejściowe.
http://pl.php.net/manual/pl/function.iconv.php


--------------------
XMPP: l0ud@chrome.pl
Go to the top of the page
+Quote Post
majestiq
post
Post #11





Grupa: Zarejestrowani
Postów: 235
Pomógł: 0
Dołączył: 26.10.2006

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


Spoko. Już sobie poradziłem.
Dzięki za wskazówki.


--------------------
Free mp3 download.
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 Aktualny czas: 20.08.2025 - 11:18