lauralee Posted November 28, 2010 Share Posted November 28, 2010 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>'); }?> Link to comment Share on other sites More sharing options...
Ingolme Posted November 28, 2010 Share Posted November 28, 2010 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. Link to comment Share on other sites More sharing options...
lauralee Posted November 29, 2010 Author Share Posted November 29, 2010 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. Link to comment Share on other sites More sharing options...
boen_robot Posted November 29, 2010 Share Posted November 29, 2010 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.