escape apostrophes html form


i have a php form and sometimes my database error because of the apostrophe in the form how can i overcome this error