Hi,here is a complete code in php which you can try
html form part
<input type="text" name="test" />
<input type="submit" name="submit" value="ok" />
php script to insert value in data
$link = mysql_connect("host","username","passord");
echo $var; //here is the form variable which user enter in the form contain apostrophe
echo "don't"; //here is test for echoing the variable that contain apostrophe
$query1="insert into table_name(column_name)values(\"$var\")"; //variable to store in the database
echo "not inserted";
when you run tihs code enter table name in the place of table_name and column name in the place of column_name and run the query.
it will print same as you have entered in the form field.
I think this will help you.