Warning: preg_match () [function. preg-match]: Compilationfailed: nothingtorepeat solution

Source: Internet
Author: User
Tags preg
Warning: preg_match () [function. preg-match]: Compilationfailed: nothingtorepeatWarning: preg_match () [function. preg-match]: Compilationfailed: nothingtorepeatatoffset0inE: E Warning: preg_match () [function. preg-match]: Compilation failed: nothing to repeat
Warning: preg_match () [function. preg-match]: Compilation failed: nothing to repeat offset 0 in E: \ EasyPHP-5.3.4.0 \ www \ 01 \ note_check.php on line 9 how to modify, hope the experts help me ah?
The procedure is as follows:
Error_reporting (E_ALL ^ E_NOTICE );
Require ("global. php ");
If ($ _ POST ){
If (is_file ("./filterwords.txt") {// Determine whether the given file name is a normal file
$ Filter_word = file ("./filterwords.txt"); // read the entire file into an array.
$ Str = $ _ POST ['content'];
For ($ I = 0; $ I If (preg_match ("/". trim ($ filter_word [$ I]). "/I", $ str) {// use a regular expression to determine whether the sent message contains sensitive words.
Echo "script" alert ('the message contains sensitive words! '); History. back (-1); script ";
Exit;
}
}
}
$ Content = $ _ POST ['content'];
$ User_name = $ _ POST ['User _ name'];
$ Title = $ _ POST ['title'];
$ Mood = $ _ GET ['mood '];
$ Head = $ _ POST ['head']. ". gif ";
$ Note_flag = $ _ POST ['checkbox'];
If ($ note_flag! = 1) {$ note_flag = 0 ;}
$ Datetime = date ("Y-m-d H: I: s ");
$ SQL = "insert into tb_note (note_user, note_title, note_content, note_mood, note_time, note_user_pic, note_flag) values ('". $ user_name. "','". $ title. "','". $ content. "','". $ mood. "','". $ datetime. "','". $ head. "','". $ note_flag. "')";
$ DB-> query ($ SQL );
$ Url = "./index. php ";
Redirect_once ($ url );
}
?>

------ Solution --------------------
Your $ filter_word [$ I] contains perl reserved words, especially? , + ,*
Escape
Which of the following statements is true?
Preg_match ("/". preg_quote (trim ($ filter_word [$ I]). "/I", $ str)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.