Problems with Polish letters |
Problems with Polish letters |
16.09.2010, 21:15:31
Post
#1
|
|
Grupa: Zarejestrowani Postów: 7 Pomógł: 0 Doł±czył: 16.09.2010 Ostrzeżenie: (0%) |
Hello All!
Apologies for my lack of Polish and apologies if this has gone in the wrong forum. I'm creating a website where you enter your details in text boxes on an .html page, which you then review on a .php page. Everything has been changed to utf-8. The problem is when you enter Polish characters in the text box, on the next page when you review the information and say whether it's good or not, the Polish characters show up as "Auml�Auml�Auml�Aring�" Any idea what the problem could be? Many thanks in advance |
|
|
16.09.2010, 22:14:15
Post
#2
|
|
Grupa: Zarejestrowani Postów: 258 Pomógł: 17 Doł±czył: 22.05.2007 Ostrzeżenie: (0%) |
Maybe you keep this info in DB which is not set as utf8.
Try execute
after connect to db. -------------------- |
|
|
16.09.2010, 22:20:21
Post
#3
|
|
Grupa: Zarejestrowani Postów: 7 Pomógł: 0 Doł±czył: 16.09.2010 Ostrzeżenie: (0%) |
The problem happens before the Polish letters get to the DB. The process is like this:
index.html -> where you enter Polish characters in text fields review.php -> you check to see if your info is correct **This is where I have the problems with the letters** submit.php -> info is sent to DB The code on review.php is
|
|
|
16.09.2010, 22:39:03
Post
#4
|
|
Grupa: Zarejestrowani Postów: 120 Pomógł: 22 Doł±czył: 15.07.2008 Sk±d: Raniżów/Rzeszów Ostrzeżenie: (0%) |
Check the file encoding and set it at utf-8, next try the sugestion of @mrok.
|
|
|
17.09.2010, 11:49:41
Post
#5
|
|
Grupa: Zarejestrowani Postów: 18 Pomógł: 2 Doł±czył: 9.03.2007 Ostrzeżenie: (0%) |
I think the problem is with htmlentities. Insert it after ereg_replace.
Ten post edytował mandragorek 17.09.2010, 11:51:10 |
|
|
17.09.2010, 13:04:20
Post
#6
|
|
Grupa: Zarejestrowani Postów: 7 Pomógł: 0 Doł±czył: 16.09.2010 Ostrzeżenie: (0%) |
Thanks for answering, however I'm a complete idiot and new to php. Do you want me to try:
$firstname = ereg_replace htmlentities("[^0-9a-zA-Z?±ćęłń󶿼ˇĆĘŁŃÓ¦Ż¬ ]", "", $string1); This gives me the error: Parse error: syntax error, unexpected T_STRING in /home/englas/public_html/znajdejezyk.pl/studentpreinsertpl.php on line 82 I also tried: $firstname = ereg_replace (htmlentities("[^0-9a-zA-Z?±ćęłń󶿼ˇĆĘŁŃÓ¦Ż¬ ]", "", $string1)); And that gave me some warnings on the page: Warning: htmlentities() expects parameter 2 to be long, string given in ***** on line 82 Warning: Wrong parameter count for ereg_replace() in ***** on line 82 Ten post edytował doodlebug 17.09.2010, 13:12:19 |
|
|
17.09.2010, 13:13:40
Post
#7
|
|
Grupa: Zarejestrowani Postów: 18 Pomógł: 2 Doł±czył: 9.03.2007 Ostrzeżenie: (0%) |
I thought about
Probably after first line in your script in variable $string1 you get text where some letters are replaced with their html entities. Ten post edytował mandragorek 17.09.2010, 13:28:08 |
|
|
17.09.2010, 13:26:59
Post
#8
|
|
Grupa: Zarejestrowani Postów: 30 Pomógł: 0 Doł±czył: 9.09.2010 Ostrzeżenie: (0%) |
Hi,
first of all, use preg_replace because ereg is deprecated. Second, you should use htmlspecialchars instead of htmlentities i think. Last thing, check meta tag on the webpage if you have utf-8 encoding. After that check if you have utf-8 in your database. You receive ? because web browser don't know what to do with additional byte. You should know that iso-8859-2 (latin2) use 1 byte to encode a character. UTF-8 need 1 byte for first 128 characters (ASCII), then 2 bytes after that. When you display utf-8 string as latin2, all characters above US-ASCII table are displayed wrong because it display each of the two bytes separately and not as one char. Ten post edytował dariuszp 17.09.2010, 13:28:11 |
|
|
17.09.2010, 13:50:18
Post
#9
|
|
Grupa: Zarejestrowani Postów: 7 Pomógł: 0 Doł±czył: 16.09.2010 Ostrzeżenie: (0%) |
Thanks for the suggestion Mandragorek - but no luck
dariuszp - thanks for the suggestion. The meta tags are all utf 8, charsets are all UTF 8 on all pages -php and html database: MySQL charset: UTF-8 Unicode (utf8) MySQL connection collation: utf-8_unicode_ci I tried preg_replace and used htmlspecialchars but it still didn't work. I tried changing the charset to iso-8859-2 and that just messed up the whole page LATEST NEWS********* The code now looks like:
This now produces a blank field rather than symbols - any ideas what's going on? Ten post edytował doodlebug 17.09.2010, 13:56:35 |
|
|
17.09.2010, 14:47:46
Post
#10
|
|
Grupa: Zarejestrowani Postów: 23 Pomógł: 2 Doł±czył: 17.09.2010 Ostrzeżenie: (0%) |
Hey,
First of all look at the source code of your site for polish characters. Maybe your browser is set to some strange encoding . Second thing: try to add this line after your connection code: It may help. |
|
|
17.09.2010, 16:08:23
Post
#11
|
|
Grupa: Zarejestrowani Postów: 7 Pomógł: 0 Doł±czył: 16.09.2010 Ostrzeżenie: (0%) |
Hi Goran - the extra line made no difference
Source code looks ok - everything is UTF-8 |
|
|
17.09.2010, 16:16:19
Post
#12
|
|
Grupa: Zarejestrowani Postów: 30 Pomógł: 0 Doł±czył: 9.09.2010 Ostrzeżenie: (0%) |
Hmmm... if all files, database and website use UTF-8 then i have no idea what's wrong. You can try what goran send you. Anyway, also try something like that:
Kod $string1 = isset($_POST['firstname']) ? $_POST['firstname'] : false;
if(empty($string1)) { echo("<h2>Imię:<font color=red>Prozsę wypełnić</font></h2>\n"); $showbutton=1; } else { $firstname = preg_replace ("[^0-9a-zA-Z?±ćęłń󶿼ˇĆĘŁŃÓ¦Ż¬ ]", "", $string1); $firstname = htmlspecialchars($firstname); echo("<h2><span class=profile>Imię:</span> <font color=#04B404>" . $firstname . "</font></h2>\n"); echo("<input type=hidden name=firstname value=" . $firstname . ">"); |
|
|
17.09.2010, 20:49:37
Post
#13
|
|
Grupa: Zarejestrowani Postów: 1 590 Pomógł: 185 Doł±czył: 19.04.2006 Sk±d: Gdańsk Ostrzeżenie: (0%) |
Hello. I know problem with local artificial letter and recommended use http://pl2.php.net/manual/en/book.mbstring.php and mb_* function, example for check encoding:
http://pl2.php.net/manual/en/function.mb-detect-encoding.php Try check encoding from received POST, during insert to db and from db. |
|
|
17.09.2010, 21:07:48
Post
#14
|
|
Grupa: Zarejestrowani Postów: 258 Pomógł: 17 Doł±czył: 22.05.2007 Ostrzeżenie: (0%) |
Try use var_dump(variable) in few lines in your code and check if $variable has expected value.
First parameter in preg_replace does not look like correct regex pattern. -------------------- |
|
|
Wersja Lo-Fi | Aktualny czas: 17.04.2024 - 15:07 |