i have an ajax form posting into a sql db and would like to backslash single, double quotes and the backslash itself, this doesnt seem to work from a <input /> field
would i have to turn all those regex into 1 concise statement?Code:$old = $_POST['title']; $newTitle = trim( preg_replace('/\\\\/','\\\\\\\\',$old) ); // backslash a backslash \\ $newTitle = trim( preg_replace( '/[\"]/', '\"', $old ) ); // backslash the double quotes \" $newTitle = trim( preg_replace( '/[\']/', '\"', $old ) ); // backslash the single quotes \' mysql_query("UPDATE `mytable` SET title ='$newTitle' WHERE id='$id'");



Reply With Quote

Bookmarks