Single quote ( ' ) is not saving in my database php

Viewed 51

I have a textbox where it accepts the comments and also all the special characters. It accepts all the special characters but when I try to save using a single quote ( ' ) in a sentence it's not saving. It keeps on loading the page. Down below is the code I have

<tr>
  <td><span>Description</span></td>
  <td class="upper-buttons">
    <button onclick="update_description($('#t_description'))">
      Save Description
    </button>
  </td>
</tr>
<tr>
  <td colspan="3">
    <textarea id="t_description" class="no-focus-class" >{$arr[0]['Description']}></textarea>
  </td>
</tr>

I have the below I tried the function

$tid =  trim($_POST['tid']);
$desc = trim($_POST['desc']);

iconv(mb_detect_encoding($desc, mb_detect_order(), true), "UTF-8", $desc);

$sql = "update [trainings] set [Description] = N'{$desc}' where [TrainingID] = '{$tid}'";

if(CommandExe($sql)){
  echo "Description updated";
}
else{
  echo "Description error";
}

and even I tried $desc = mysql_real_escape_string(trim($_POST['desc'])) and in my header I even added header("Content-Type: text/html; charset=utf-8"). But still, it doesn't work. How do I fix it?

0 Answers
Related