Авторизация
 Регистрация   Войти   Забыли пароль? 

Сохранение обратных слешей при добавлении и извлечении текста из БД. Вместо stripslashes() и addslashes()

Обновлённый PHP-Fusion Bogatyr / Free CMS PHP-Fusion 7 Bogatyr / PHP-functions for text / Сохранение обратных слешей при добавлении и извлечении текста из БД. Вместо stripslashes() и addslashes()


 Russian

Функции добавляют или удалят слеши перед двойными и одинарными кавычками. Это необходито для добавления и извлечения текстов из БД.
Но не затрагивают прочие слеши перед другими символами, например n r и т. д. Такие символы используются в PHP-коде часто и регулярных выражениях типа preg_match().

Saving backslashes when adding and extracting text from the database. Instead of stripslashes() and addslashes()

Обновлённый PHP-Fusion Bogatyr / Free CMS PHP-Fusion 7 Bogatyr / PHP-functions for text / Saving backslashes when adding and extracting text from the database. Instead of stripslashes() and addslashes()


 English

Functions add or remove slashes before double and single quotes. This is necessary for adding and extracting texts from the database.
But they do not affect other slashes in front of other symbols, for example, n r, etc. Such symbols are used in PHP code frequently and regular expressions Type preg_match ().

PHP

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\mail_bbcode_include.php on line 20

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\mail_bbcode_include.php on line 21

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\search_bbcode_include.php on line 39

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\mail_bbcode_include.php on line 20

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\mail_bbcode_include.php on line 21

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\search_bbcode_include.php on line 39

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\mail_bbcode_include.php on line 20

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\mail_bbcode_include.php on line 21

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\search_bbcode_include.php on line 39

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\mail_bbcode_include.php on line 20

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\mail_bbcode_include.php on line 21

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\search_bbcode_include.php on line 39

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\mail_bbcode_include.php on line 20

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\mail_bbcode_include.php on line 21

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\search_bbcode_include.php on line 39
PHP
  1. <?php
  2. $slash =  str_replace(' ', '', ' \ ');
  3. $quot2 = '"'; $quot1 = "'";
  4. function delquotslashes($text=""){
  5.     global $slash, $quot2, $quot1;
  6.     $text = str_replace($slash.$quot2 , $quot2, $text);
  7.     $text = str_replace($slash.$quot2 , $quot2, $text);
  8.     $text = str_replace($slash.$quot1 , $quot1, $text);
  9.     $text = str_replace($slash.$quot1 , $quot1, $text);
  10.     return $text;
  11. }
  12. function addquotslashes($text=""){
  13.     global $slash, $quot2, $quot1;
  14.     $text = str_replace($quot2, $slash.$quot2 , $text);
  15.     $text = str_replace($quot1, $slash.$quot1 , $text);
  16.     return $text;
  17. }
  18. ?>



// RU: обновление БД // до
// EN: Database update // before
PHP
  1. <?php
  2. $q = "UPDATE ".DB_PREFIX."phpfuncs SET
  3. description='".addslashes(stripslashes(stripslashes($description])))."'
  4. WHERE id='".$id."' ";
  5. ?>


// RU: // после
// EN: // after
PHP
  1. <?php
  2. $q = "UPDATE ".DB_PREFIX."phpfuncs SET
  3. description='".addquotslashes($description])."'
  4. WHERE id='".$id."' ";
  5. ?>


// RU: Получение текста // до
// EN: Getting the text // before
PHP
  1. <?php
  2. $description = stripslashes($_POST['description']);
  3. ?>

// после // after
PHP
  1. <?php
  2. $description =  delquotslashes($_POST['description']);
  3. ?>


Добавить комментарий

Добавить комментарий
Пожалуйста, залогиньтесь для добавления комментария.
Рейтинги
HTML-code and BB-code for blogs and forums

<a href="https://php-fusion.vveb.ws/php-fusion.php?id=30">Сохранение обратных слешей при добавлении и извлечении текста из БД. Вместо stripslashes() и addslashes()</a>


[url=https://php-fusion.vveb.ws/php-fusion.php?id=30]Сохранение обратных слешей при добавлении и извлечении текста из БД. Вместо stripslashes() и addslashes()[/url]

Language: Default
 
Код для PHP-Fusion