chizijs
chizijs

Reputation: 159

Code is adding backslash before apostrophe

For example I writed this text is I don't know and submited it to database. Then I go to page, where this text appears and it show I don\'t know, how can I disable adding backslashes?

code

$text= htmlspecialchars($db['text']);
$textA = array('/\[b\](.*?)\[\/b\]/is');
$textB = array('<b>$1</b>'); 
$textC = preg_replace($textA,$textB,$text);
echo nl2br($textC);

Upvotes: 1

Views: 4527

Answers (2)

user2742371
user2742371

Reputation:

Turn magic_quotes off in your .htaccess file by adding this line:

php_flag magic_quotes_gpc Off

Upvotes: 1

Maxim Krizhanovsky
Maxim Krizhanovsky

Reputation: 26699

Turn off magic_quotes_gpc and make sure you are not using addslashes before saving to the database

Upvotes: 2

Related Questions