Reputation: 1413
textarea post gets diffrent result with or without "\"?
the same code runs in different pc , get the diffrent result
my systerm is xp , and I post textarea and print it , the result has "\" befror ' , but I run it in other guy's pc ,the result returns no "\".
this defferent result cause that when I insert mysql , returns error when the sql has no "\"
why this happen ? how to fix ?
<pre>
<?php
print_r($_POST);
?>
</pre>
<form method="post">
<textarea name="content" id="" cols="30" rows="10">This is kate's book</textarea>
<input type="submit" />
</form>
in my pc ,get:
this is kate\'s book
in others, get:
this is kate's book
add in htaccess is ok
php_flag magic_quotes_gpc 1
Upvotes: 2
Views: 47
Reputation: 301
Probably the php configurations are different between you and your friend computer. Try to use php function stripslashes.
$var = stripslashes($another_var);
Upvotes: 1
Reputation: 7077
The problem here comes from the magic_quotes_gpc
setting in your php.ini. You have to turn it off: this thing is pure evil (and deprecated). It "escapes" your data automagically.
However, you still want it escaped. The best way to do that is by using PDO and prepared requests.
Upvotes: 3