使用输入类型撇号插入或更新查询故障

i have trouble with adding value in database. When i add value in input type with out apostrophe then it's working. Example:

<input type="text" id="sample" name="sample" value="it is good">

But when i put the value with apostrophe it's not working. For example:

<input type="text" id="sample" name="sample" value="it's good">

at php use $var = mysql_real_scape_string($_POST); you need to escape it.

$sample = htmlspecialchars($sample,ENT_QUOTES);

this is working. The value is store with "&#39" for "'".

Thanks guys for your help.