Support Forum

Warning | htmlspecialchars(): Invalid multibyte sequence in argument

SN Snabel
Snabel
Member

Hi
I have a strange problem. My error log is filled up since yesterday by a lot of the following messages.

file: /simple-press/sp-api/sp-api-filters.php
line: 1704
function: htmlspecialchars
Warning | htmlspecialchars(): Invalid multibyte sequence in argument

The strange thing is that I cloned the entire site with Duplicator and test it in Localhost but everything looks good, no error code in the log.
I have the latest version of sp and all plugins, the only configuration that has changed is that I activated the polls that works well.

What can cause these error codes on my live site but does not show anything in the log on the cloned site in Localhost?
The error codes are generated only on live site, what can it be?

Does anyone recognize the error code?

Regards
Snabel

10 Answers

New Answer

YS Yellow Swordfish
Yellow Swordfish
Member

That would suggest a CHARSET problem.That routine uses the charset that is set by your wp-config.php so maybe there is something in a forum post (and it WILL: be in a post) that breaks the charset in some way… perhaps some unexpected characters in a post or something…

MP Mr Papa
Mr Papa
Member

no, have not seen this before… but might be able to offer a suggestion… but some questions first…

on the two sites (live and local) what is the char set in use for the db?  and any chance you are using php 5.4? 

Are all your posts displaying properly? can you ‘make’ it happen on specific post content?

the 5.4 version of php has made a change to the way htmlspecialchars() works or at least potentially.. and for ‘nonstandard’ charsets this can cause it to behave differently.  In our next version we (and WP in 3.6) have changed the way we use that function to try to handle this…

so perhaps you could change that line 1704 to:

        $content = htmlspecialchars($content, ENT_QUOTES, SFCHARSET);

assuming that is the same line (we added the SFCHARSET part)…  and see if that helps…

SN Snabel
Snabel
Member

Everything works in general as it should.
I tried changing the line in 1704 but there was no difference.

Live site has PHP Version: 3.5.10-1ubuntu3.6 and MySql Version: 5.5.29  Server: Version: Apache/2.2.22
Localhost, PHP Version: 5.4.7 and MySql Version: 5.5.27  Server: Apache/2.4.3
Both sites run UTF8 as they should

Since only one of the sites affected by error codes and sites in general are identical while the server environment to my knowledge has not changed it should reasonably happened something with my host.
I wait a day and keep track of the log before contacting them.

I thank you for the answers so far and will return when there is more to tell.
/Snabel

YS Yellow Swordfish
Yellow Swordfish
Member

I don’t follow the php version on your live site? Is that seriously V3 of php? WordPress needs version 5.2.4 of php as minimum – as does SP. So I assume I am missing something here?

SN Snabel
Snabel
Member

Yellow Swordfish said
I don’t follow the php version on your live site? Is that seriously V3 of php? WordPress needs version 5.2.4 of php as minimum – as does SP. So I assume I am missing something here?

Sorry:

PHP Version: 5.3.10-1ubuntu3.6

 

KE Kenn
Kenn
Member

Snabel:

Did you ever work out what it was? Our error log is full of the same notice.

 

MP Mr Papa
Mr Papa
Member

did you try the fix in post 3?  what is the charset/coallation on your db?

KE Kenn
Kenn
Member

Thanks for the quick reply, appologies I had overlooked the fix in post 3, have changed now and will wait to see if it stops the error it appears every 15-20mins so should be able to notice quite quickly.

UTF-8 Charset

MP Mr Papa
Mr Papa
Member

hope it works, but illegal characters in a post will do it too.. how do the illegals get in there? dont know – usually seems to be if you move servers and the database collation gets changed…

but let us know…