Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   Polish characters on site (http://www.go4expert.com/forums/polish-characters-site-t12961/)

reQuorter 16Aug2008 00:25

Polish characters on site
Hello everyone,

I am starting with my PHP adventure with this tutorial:


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:



<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="pl" />


@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">
<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" />

<h2>All Quotes:</h2>

$query="SELECT `quote`, `author` FROM `quotes`";
$result=mysql_query($query) or die(mysql_error());
while ($i < $num) {
$quote = htmlentities(mysql_result($result,$i,"quote"));
$author = htmlentities(mysql_result($result,$i,"author"));
echo("<blockquote>" . $quote . " ~ <cite>" . $author . "</cite></blockquote>");

All times are GMT +5.5. The time now is 00:36.