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)