• Resolved 4boards

    (@4boards)


    Any ideas how to fix the following error?

    23-Nov-2014 10:04:05 UTC] PHP Warning: htmlspecialchars() [function.htmlspecialchars]: Invalid multibyte sequence in argument in /home/boardsc/public_html/wp-includes/formatting.php on line 3205

    This is a regular error message.

    Here are details that may be pertinent:

      From line 3204 WP-INCLUDES/FORMATTING.PHP

    function esc_textarea( $text ) {
    $safe_text = htmlspecialchars( $text, ENT_QUOTES, get_option( ‘blog_charset’ ) );
    /**
    * Filter a string cleaned and escaped for output in a textarea element.
    *
    * @since 3.1.0
    *
    * @param string $safe_text The text after it has been escaped.
    * @param string $text The text prior to being escaped.
    */
    return apply_filters( ‘esc_textarea’, $safe_text, $text );
    }

      SITE (www.4boards.co.uk) PHP.INI code for character set

    PHP.INI
    ; As of 4.0b4, PHP always outputs a character encoding by default in
    ; the Content-type: header. To disable sending of the charset, simply
    ; set it to be empty.
    ;
    ; PHP’s built-in default is text/html
    default_mimetype = “text/html”
    ;default_charset = “iso-8859-1”

      Character set setting for database in WP-CONFIG.PHP

    /** Database Charset to use in creating database tables. */
    define(‘DB_CHARSET’, ‘utf8’);

Viewing 14 replies - 1 through 14 (of 14 total)
  • Do you have a way to confirm the blog_charset option value in your database is 'utf8', eithe rby looking in your db (eg, via PHPmyAdmin) or printing the value somewhere:
    echo get_option( 'blog_charset' )

    That’s what I’d check first anyway. Also you didn’t mention which if you get the warning on all or just some pages at:
    http://www.4boards.co.uk

    Thread Starter 4boards

    (@4boards)

    I have checked via PHPmyAdmin

    4boards
    wp_options
    blog_charset

    IT IS UTF-8

    When I open PHPmyAdmin the Database server panel contains:
    Server: Localhost via UNIX socket
    Server type: MySQL
    Server version: 5.5.40-cll – MySQL Community Server (GPL)
    Protocol version: 10
    User: boardsc@localhost
    Server charset: UTF-8 Unicode (utf8)

    The GENERAL SETTINGS panel shows;
    “Server collation connection” “utf8mb4_general_ci”

    4boards, that’s all I can think of, except if the charset isn’t the issue then a string in the $text var sent to the function esc_textarea( $text ) might have some issues.

    Is a plugin sanitizing text by using than function?
    http://codex.ww.wp.xz.cn/Function_Reference/esc_textarea

    I’m getting the same thing from my Contact Form, I was putting it down to spambots or similar as the form functions properly and I get contact messages from it. I haven’t explored in depth and the messages only started to appear after the last WP update.

    mod_fcgid: stderr: PHP Warning: htmlspecialchars(): Invalid multibyte sequence in argument in*****gloucesterphotographer/wp-includes/formatting.php on line 3205, referer: http://www.gloucesterphotographer.com/contact-me/

    I started to get the same message but with line 3192 in formatting.php. I tweaked my contact form and the error message has moved to 3205.

    line 3192 is this bit..

    function esc_textarea( $text ) {
    $safe_text = htmlspecialchars( $text, ENT_QUOTES, get_option( ‘blog_charset’ ) );
    /**
    * Filter a string cleaned and escaped for output in a textarea element.
    *
    * @since 3.1.0
    *
    * @param string $safe_text The text after it has been escaped.
    * @param string $text The text prior to being escaped.
    */
    return apply_filters( ‘esc_textarea’, $safe_text, $text );
    }

    Sorry for rambling… I can’t figure it out but my contact page is pretty simple if it helps get to the bottom of it.

    All best
    SI

    http://www.gloucesterphotographer.com

    The contact form and it happening since WP 4.0.1 makes me suspect your contact plugin isn’t properly using the Shortcode API. I see you’ve reported this in their forum:
    https://ww.wp.xz.cn/support/topic/invalid-multibyte-sequence-textarea-escapes

    Here’s the WP announcement about shortcodes and 4.0.1:
    https://ww.wp.xz.cn/support/topic/issues-with-wordpress-401-and-shortcodes

    Do you use a shortcode to insert your contact form into the page content? Does the prob go away when you deactivate the Fast Secure Contact Form plugin? If so, then perhaps you need another contact plugin — among the popular ones are Jetpack’ and Contact Form 7.

    Thanks Hearvox. I have a Jetpack alternative contact page ready to go, I like that the current form redirects to a FAQ page after submission.
    The page is doing what it’s supposed to functionally, it just produces this error. It’s definitely only started doing it in the last couple of weeks, certainly less than a month. I’m mentioning it in the spirit of clean code rather than a problem for me.

    Many thanks
    Si.

    Thread Starter 4boards

    (@4boards)

    First instances of thsi problem were related to Line number 3192, this then became 3205 after updates.

    Is the Contact for you reference, CONTACT FORM 7?

    Can someone please advise a resolution, in English as not that WP experienced.

    Cheers
    Bob

    OK, I’ve worked out the problem with mine….

    Another site was linking through to “contact-me” rather than “contact”. It looks like WordPress was cleaning the link…

    Si.

    Hey, @glostog, please mark this topic as resolved (if, indeed, it is resolved): Thanks.

    This topic is resolved as far as I’m concerned. I think the error messages are because of a bad link and WordPress correcting the URL…
    Now…. How do I mark the topic resolved?

    All best
    Si

    Sorry, @glostog, I incorrectly thought you had started this topic. You can’t mark it as resolved: Only @4boards can.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Please make sure you open a new thread to discuss your issues in future; https://ww.wp.xz.cn/support/forum/how-to-and-troubleshooting#postform

    Ah yes, This was someone else thread which I added to with the same problem. I did start a new topic which I have closed already; that explains the confusion.
    best
    Si

    Thread Starter 4boards

    (@4boards)

    No longer an issue

Viewing 14 replies - 1 through 14 (of 14 total)

The topic ‘PHP Warning HTML Special Characters’ is closed to new replies.