SubZero. Posted August 15, 2008 Share Posted August 15, 2008 Hello everyone,I am starting with my PHP adventure with this tutorial: http://www.phazm.com/notes/easy-as-pie/eas...with-databases/Everything works fine, but when I add to database string with Polish characters (like ą, ż, ź, ć, ę, ł), I don't see them on site, instead of them I see strange characters.When I add to database through phpMyAdmin with Polish characters (like ą, ż, ź, ć, ę, ł) I see those characters in my table/rows correct (through phpMyAdmin).But when I'm displaying data on my site I again see those strange characters instead of Polish ones.MySQL Collation is utf8_bin (I also tired utf8_unicode_ci without success).I use this code: <html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta http-equiv="Content-Language" content="pl" /></head><body><?php$user="username";$password="password";$database="database";$connection=mysql_connect('localhost',$user,$password);@mysql_select_db($database) or die( "Unable to select database");if ($_REQUEST['quote'] != "") { if($_REQUEST['author'] != "") { $author = $_REQUEST['author']; } else { $author = "Anonymous"; } $quote = $_REQUEST['quote']; $query="INSERT INTO `quotes` (`quote`,`author`) values ('" . mysql_real_escape_string($quote) . "','" . mysql_real_escape_string($author) . "')"; $result=mysql_query($query) or die(mysql_error()); echo("inserted quote: " . htmlentities($quote) . " by " . htmlentities($author) . " into database");} else { echo("<p>Please enter a quote and author</p>");}?><form action="" method="post"><fieldset><legend>Add a Quote</legend><label for="quote">Quote:</label><input type="text" name="quote" id="quote" maxlength="255" /><label for="author">Author:</label><input type="text" name="author" id="author" maxlength="40" /><input type="submit" value="Add Quote" /></fieldset></form><h2>All Quotes:</h2><?php$query="SELECT `quote`, `author` FROM `quotes`";$result=mysql_query($query) or die(mysql_error());$num=mysql_numrows($result);$i=0;while ($i < $num) {$quote = htmlentities(mysql_result($result,$i,"quote"));$author = htmlentities(mysql_result($result,$i,"author"));echo("<blockquote>" . $quote . " ~ <cite>" . $author . "</cite></blockquote>");$i++;}mysql_close($connection);?> Link to comment Share on other sites More sharing options...
justsomeguy Posted August 15, 2008 Share Posted August 15, 2008 Check the section about multibyte strings:http://us2.php.net/manual/en/book.mbstring.php Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.