title: how to insert special character in mysql via php and display on html page
body: <p>how to insert special characters into a database(MySQL) like</p>
  <p><code>Registered symbol ( ® )</code> OR
  <code>Copyright sign ( © )</code> OR
  <code>Trade Mark sign ( ™ )</code></p>
  <p>Also I want to display as original on the html page.</p>
  <p>What I have to do in both side (front end and back end), please elaborate</p>
  <p>Which function is more effective?</p>
  <h3>Method 1:</h3>
  <pre><code>$_GET = array_map('trim', $_GET);
  $_POST = array_map('trim', $_POST);
   
  if(get_magic_quotes_gpc()){
    $_GET = array_map('stripslashes', $_GET);
    $_POST = array_map('stripslashes', $_POST);  
    
    $_GET = array_map('strip_tags', $_GET);
    $_POST = array_map('strip_tags', $_POST);  
   }
   else{
    $_GET = array_map('mysql_real_escape_string', $_GET);
    $_POST = array_map('mysql_real_escape_string', $_POST);   
   }
  </code></pre>
  <h3>Method 2:</h3>
  <pre><code>  foreach ($_POST as $key=&gt;$value){
          if (!get_magic_quotes_gpc()) {
            return addslashes(htmlentities(strip_tags($value),ENT_QUOTES,'UTF-8'));
            } 
            else {
               return htmlentities(strip_tags($value),ENT_QUOTES,'UTF-8');
            }
    }
  </code></pre>
  <p>I am a bit confused what is the difference between</p>
  <p><a href="http://php.net/manual/en/function.htmlentities.php" rel="nofollow noreferrer"><code>htmlentities()</code></a> and <a href="http://www.php.net/manual/en/function.htmlspecialchars.php" rel="nofollow noreferrer"><code>htlspecialchars()</code></a>, and which one i have to use?</p>
  <p>which function should be used <a href="http://www.php.net/manual/en/function.addslashes.php" rel="nofollow noreferrer"><code>addslashes()</code></a> or <a href="http://www.php.net/manual/en/function.stripslashes.php" rel="nofollow noreferrer"><code>stripslashes()</code></a> when insert into database?</p>