title: Cannot fix the cyrillic issue. htmlspecialchars/PHP/MySQL
body: <p>guys. When I type anything on cyrillic like: <code>Цветана Пиронкова</code>, and click submit (into the table), it is showing it (and saving it in the mysql table), like that: <code>&amp;amp;#1062;&amp;amp;#1074;&amp;amp;#1077;&amp;amp;#1090;&amp;amp;#1072;&amp;amp;#1085;&amp;amp;#1072; &amp;amp;#1055;&amp;amp;#1080;&amp;amp;#1088;&amp;amp;#1086;&amp;amp;#1085;&amp;amp;#1082;&amp;amp;#1086;&amp;amp;#1074;&amp;amp;#1072;</code>
  And I don't have any ideas how to fix it. I think that the problem comes from <code>htmlspecialchars</code>, but I don't know. Here is my index file:</p>
  
  <pre><code>&lt;?php // connect to the database
          include('connect-db.php');
  
          // get results from database
          $result = mysql_query("SELECT * FROM players") 
                  or die(mysql_error());  
  
  mysql_query("SET NAMES UTF8");
  
          // display data in table
          echo "&lt;p&gt;&lt;b&gt;View All&lt;/b&gt;&lt;/p&gt;";
  
          echo "&lt;table class=\"table table-bordered table-hover\" border='1' cellpadding='10'&gt;";
          echo "&lt;tr&gt; &lt;th&gt;ID&lt;/th&gt; &lt;th&gt;Mqsto&lt;/th&gt; &lt;th&gt;Ime&lt;/th&gt; &lt;th&gt;Tochki&lt;/th&gt; &lt;th&gt;&lt;/th&gt; &lt;th&gt;&lt;/th&gt;&lt;/tr&gt;";
  
          // loop through results of database query, displaying them in the table
          while($row = mysql_fetch_array( $result )) {
  
                  // echo out the contents of each row into a table
                  echo "&lt;tr&gt;";
                  echo '&lt;td&gt;' . $row['id'] . '&lt;/td&gt;';
                  echo '&lt;td&gt;' . $row['mqsto'] . '&lt;/td&gt;';
                  echo '&lt;td&gt;' . $row['ime'] . '&lt;/td&gt;';
                  echo '&lt;td&gt;' . $row['tochki'] . '&lt;/td&gt;';
                  echo '&lt;td&gt;&lt;a href="editr.php?id=' . $row['id'] . '"&gt;Edit&lt;/a&gt;&lt;/td&gt;';
                  echo '&lt;td&gt;&lt;a href="deleter.php?id=' . $row['id'] . '"&gt;Delete&lt;/a&gt;&lt;/td&gt;';
                  echo "&lt;/tr&gt;"; 
          } 
  
          // close table&gt;
          echo "&lt;/table&gt;";
          ?&gt;
  &lt;p&gt;&lt;a href="new.php"&gt;Add a new record&lt;/a&gt;&lt;/p&gt;&lt;br&gt;&lt;br&gt;
  </code></pre>
  
  <p>Here is my new.php file:</p>
  
  <pre><code>&lt;?php
  /* 
   NEW.PHP
   Allows user to create a new entry in the database
  */
  
   // creates the new record form
   // since this form is used multiple times in this file, I have made it a function that is easily reusable
   function renderForm($mqsto, $ime, $tochki, $error)
   {
   ?&gt;
   &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
   &lt;html&gt;
   &lt;head&gt;
   &lt;title&gt;New Record&lt;/title&gt;
   &lt;/head&gt;
   &lt;body&gt;
   &lt;?php 
   // if there are any errors, display them
   if ($error != '')
   {
   echo '&lt;div style="padding:4px; border:1px solid red; color:red;"&gt;'.$error.'&lt;/div&gt;';
   }
   ?&gt; 
  
   &lt;form action="" method="post"&gt;
   &lt;div&gt;
   &lt;strong&gt;Mqsto: *&lt;/strong&gt; &lt;input type="text" name="mqsto" value="&lt;?php echo $mqsto; ?&gt;" /&gt;&lt;br/&gt;
   &lt;strong&gt;Ime: *&lt;/strong&gt; &lt;input type="text" name="ime" value="&lt;?php echo $ime; ?&gt;" /&gt;&lt;br/&gt;
   &lt;strong&gt;Tochki: *&lt;/strong&gt; &lt;input type="text" name="tochki" value="&lt;?php echo $tochki; ?&gt;" /&gt;&lt;br/&gt;
   &lt;p&gt;* required&lt;/p&gt;
   &lt;input type="submit" name="submit" value="Submit"&gt;
   &lt;/div&gt;
   &lt;/form&gt; 
   &lt;/body&gt;
   &lt;/html&gt;
   &lt;?php 
   }
  
  
  
  
   // connect to the database
   include('connect-db.php');
  
  mysql_query("SET NAMES UTF8");
  
   // check if the form has been submitted. If it has, start to process the form and save it to the database
   if (isset($_POST['submit']))
   { 
   // get form data, making sure it is valid
   $mqsto = mysql_real_escape_string(htmlspecialchars($_POST['mqsto']));
   $ime = mysql_real_escape_string(htmlspecialchars($_POST['ime']));
   $tochki = mysql_real_escape_string(htmlspecialchars($_POST['tochki']));
  
   // check to make sure both fields are entered
   if ($mqsto == '' || $ime == '' || $tochki == '')
   {
   // generate error message
   $error = 'ERROR: Please fill in all required fields!';
  
   // if either field is blank, display the form again
   renderForm($mqsto, $ime, $tochki, $error);
   }
   else
   {
   // save the data to the database
   mysql_query("INSERT players SET mqsto='$mqsto', ime='$ime', tochki='$tochki'")
   or die(mysql_error()); 
  
   // once saved, redirect back to the view page
   header("Location: ranglista.php"); 
   }
   }
   else
   // if the form hasn't been submitted, display the form
   {
   renderForm('','','','');
   }
  ?&gt; 
  </code></pre>