Monday, September 20, 2010

PHP - Apostrophe problem when insert

You can use following function to avoid Apostrophe problem

function escapeSingleQuotes($string){

$singQuotePattern = "'";

$singQuoteReplace = "''";

return(stripslashes(eregi_replace($singQuotePattern, $singQuoteReplace, $string)));

}

//Calling it

$description = escapeSingleQuotes($_POST['description']);

No comments:

Post a Comment