Page 1 of 1
Entries with accents or strange characters rejected
Posted: Fri Jul 17, 2015 7:09 am
by Richard
Script URL:
http://www.richardackermann.ch/gbook/gbook.php
Version of script: 1.7.2 and 1.5
Hosting company: Webopolis Switzerland
URL of phpinfo.php: --
URL of session_test.php: --
What terms did you try when SEARCHING for a solution:
PHP 5.4 guest book accents strange characters
Write your message below:
Hello!
The server hosting my guestbook was recently updated to PHP 5.4, and ever since every attempt to sign the guestbook with a text containing either accents or strange characters (such as ö/ä/ü or é/à/ô) is rejected: the entry field is cleared and the warning message says "please enter your comment".
However, old comments written with accents are still correctly displayed in the guest book.
Of course, this is not an issue for English speaking visitors, but my website is in English-German-French...
I am still using version 1.5 on my website (who worked perfectly fine until the PHP update), but to run a test on this issue, I updated it temporarily to the latest version 1.7.2., with the same result
Any idea where the culprit is? Is version 1.7.2. compatible with PHP 5.4?
Thanks for your precious help!
Richard (Switzerland)
Re: Entries with accents or strange characters rejected
Posted: Tue Jul 21, 2015 6:07 pm
by Klemen
Hello,
Could you please try this and let me know if it fixes your issue:
1. open gbook.php in a text editor
2. find line
3. change it to:
Code: Select all
$in = htmlspecialchars($in, ENT_COMPAT | ENT_SUBSTITUTE | ENT_XHTML, 'UTF-8');
4. Save, upload and test.
Re: Entries with accents or strange characters rejected
Posted: Tue Aug 04, 2015 3:16 pm
by the fool on the hill
Hi, I'm using 1.7 in French and I have the same problem. I changed the line of code as suggested and that allowed the poster to submit. But not all accents are recognised. For example û is fine but ô is not. I edited the post manually and then noticed that all existing posts were affected, ie some letters are replaced by nonsense.
Is there a solution ?
Thanks in advance - The Fool
Re: Entries with accents or strange characters rejected
Posted: Wed Aug 05, 2015 6:35 pm
by Klemen
Looks like the script needs to be updated to use UTF-8 encoding.
I will try to prepare an update as soon as possible, probably in the next few weeks.
Re: Entries with accents or strange characters rejected
Posted: Thu Mar 10, 2016 4:39 am
by Jokus08
I just registered to stop by in this particular thread. Has there been any progress in this matter?
I installed GBook 1.72 on my site and customized the css, only to find out afterwards that I cannot use it in my language area. D'oh!
"Ää", "Öö", "Üü" and "ß" all turn into "ďż˝"... Without the
Code: Select all
$in = htmlspecialchars($in, ENT_COMPAT | ENT_SUBSTITUTE | ENT_XHTML, 'UTF-8');
fix from above, GBook would not even accept any entry including these umlauts at all. Took me a while to figure out what was going on!
From what I can tell GBook is a great piece of software. I just wish this major flaw could get sorted out as soon as possible. As it stands right now a large part of the user base is locked out from using it. Or am I doing something wrong?
Re: Entries with accents or strange characters rejected
Posted: Thu Mar 10, 2016 8:04 am
by Klemen
The underlying fault is in actually in PHP itself, when they changed the default settings and modified the way htmlspecialchars function works. It's been discussed and frowned upon a lot in the PHP community (with the dreaded "it's not a bug, it's a feature" excuse from PHP core developers), especially because the htmlspecialchars doesn't even generate an error or a notice, just discards all the text.
Anyway, I know an update to GBook is long due. I am currently finishing a complete rewrite of LinkMan and will work on getting GBook updated next.
Re: Entries with accents or strange characters rejected
Posted: Thu Mar 10, 2016 5:43 pm
by Jokus08
Thank you for the quick reply and all the great software you provide us with! Do you think the character set problem can be solved in your next release?
I know next to nothing about php but would it be possible to implement a dirty fix for the time being that replaces a given set of characters with acceptable ones at the time of submitting the comment? Something along the lines of this javascript function:
The results would still be kind of awkward, but the character replacements ä -> ae, ö -> oe, ü -> ue, ß -> ss are somewhat accepted over here.
It would help bridge the time till your new release will be out. And one could always go manually over the entries.txt file with "search & replace" afterwards, filling in the original characters once the new GBook copes with this character problem.
Re: Entries with accents or strange characters rejected
Posted: Thu Mar 10, 2016 7:10 pm
by Klemen
The char problem will definitely be solved in the next release as the entire GBook will move to UTF-8 encoding.
Can you post the URL of your guestbook and
phpinfo.php file on your server?
Re: Entries with accents or strange characters rejected
Posted: Thu Mar 10, 2016 7:20 pm
by Jokus08
Hello, the site is not officially live yet, so I'd prefer to send you the link in a pm. Hope that's ok with you! I'm always ready to help you out with testing if you need someone.
Re: Entries with accents or strange characters rejected
Posted: Sat Mar 12, 2016 9:45 am
by Klemen
Here is the full solution for anyone having the same problem (will also be included in the future update):
1. Download and install this free but powerful text editor:
Notepad++
2. open file
gbook.php in Notepadd++
3. find line
4. change it to:
Code: Select all
$in = htmlspecialchars($in, ENT_COMPAT | ENT_SUBSTITUTE | ENT_XHTML, 'UTF-8');
5. Save changes to gbook.php
6. Open file
language.inc.php file in Notepad++
7. in top menu click "Encoding" > "Convert to UTF-8" (the option without "BOM")
8. change line
to
9. save the file and upload to the server
10. open guestbook in browser, refresh it and submit a new test post
Re: Entries with accents or strange characters rejected
Posted: Sat Mar 12, 2016 11:13 am
by Jokus08
Stellar work, thank you Klemen for the support ! Everything is working fine now. I'm not even sure a company with an expensive maintenance contract would have come up with a fix this quick

Re: Entries with accents or strange characters rejected
Posted: Sat Mar 12, 2016 3:46 pm
by Klemen
You are welcome, thank you for testing this for me.
Re: Entries with accents or strange characters rejected
Posted: Sat Mar 12, 2016 4:08 pm
by einarkol
Try saving your files in: UTF-8 - NO BOM
It did the trick for me.
Einar