Jump to content
Sign in to follow this  
lauralee

Setting charset

Recommended Posts

I have attempted to include mysql_set_charset in my connection as suggested in a previous forum discussion as shown in the CONNECTION CODE below, but I receive this error. Warning: htmlspecialchars() [function.htmlspecialchars]: charset `UTF8' not supported, assuming iso-8859-1 in /home/lauralee/public_html/test127/includes/helpers.inc.html.php on line 6.When the following function is called:function html($text) { return htmlspecialchars($text, ENT_QUOTES, 'UTF8'); }Where and how do I set the charset to UTF-8?CONNECTION CODE USED: <?php // Connect to the database server $link = @mysql_connect('localhost', '***', '***)'); if (!$link) { exit('<p>Unable to connect to the ' . 'database server at this time.</p>'); } mysql_set_charset('utf8'); // Select the *** database if (!@mysql_select_db('***_***')) { exit('<p>Unable to locate the *** ' . 'database at this time.</p>'); }?>

Share this post


Link to post
Share on other sites

It should be "UTF-8" with a hyphen.Anyways, quoting the manual:

For the purposes of this function, the charsets ISO-8859-1, ISO-8859-15, UTF-8, cp866, cp1251, cp1252, and KOI8-R are effectively equivalent, as the characters affected by htmlspecialchars() occupy the same positions in all of these charsets.
It doesn't really matter if you don't specify a character set for that function.

Share this post


Link to post
Share on other sites

Thanks! That did the trick. I didn't realize I had left out the hyphen. Its those little details that make things come to a screeching halt.

Share this post


Link to post
Share on other sites

For the record, "utf8" is indeed the correct value to supply to mysql_set_charset(). It's just not the right value to htmlspecialchars(). When in doubth, read the manual, and use whatever it says there.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...