apostrophe issue with ajax post to php

Posted by Ahmet vardar on Stack Overflow See other posts from Stack Overflow or by Ahmet vardar
Published on 2010-06-10T16:47:34Z Indexed on 2010/06/10 17:12 UTC
Read the original article Hit count: 346

Filed under:
|

hi there,

i am posting data with jquery ajax to php but if input has ' inside, data wont be posted. I tried encodeURIComponent but wont work.

any idea on this ?

thanks

EDIT: my code

var name = $("input#name_add").val();
         name = encodeURIComponent(name);

$.post("function.php", { name: name }, function(data) {

                               //codes
                });



$query = "UPDATE `table` SET name = '" . stripslashes($_POST['name']) . "' WHERE ID = '$id'";
$result = mysql_query($query);
if ($result){
print "ok";

}

© Stack Overflow or respective owner

Related posts about php

Related posts about AJAX