[英]Compilation failed: range out of order in character class at offset 12
I have a very basic HTML form with text boxes defined as 我有一个非常基本的HTML表单,其中的文本框定义为
<li id="li_1" >
<label class="description" for="element_1">O teu nome </label>
<span>
<input id="element_1_1" name= "element_1_1" class="element text" pattern="[a-z0-9. -]+" maxlength="255" size="8" value=""/>
<label>Primeiro</label>
</span>
<span>
<input id="element_1_2" name= "element_1_2" class="element text" pattern="[a-z0-9. -]+" maxlength="255" size="14" value=""/>
<label>Apelido</label>
</span>
This input is validated in a php file called email_send_pt.php using 此输入使用以下文件在名为email_send_pt.php的php文件中进行验证:
// validation expected data exists
if(!isset($_POST['element_1_1']) ||
!isset($_POST['element_1_2']) ||
!isset($_POST['element_2']) ||{
died('Lamentamos, mas constam erros no seu registo.');
}
$first_name = $_POST['element_1_1']; // required
$second_name = $_POST['element_1_2']; // required
$email = $_POST['element_2']; // required
$error_message = "";
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name) ||
!preg_match($string_exp,$second_name)) {
$error_message .= 'O nome que preencheu não parece ser válido.<br />';
}
I am getting a constant "Compilation failed: range out of order in character class at offset 12 in email_send_pt.php on line 45" 我得到一个常量“编译失败:字符类的范围乱序,第45行的email_send_pt.php中偏移量12”
Line 45 is "if(!preg_match($string_exp,$first_name) ||" As input I used "teu" (without "") which should be accepted… 第45行是“ if(!preg_match($ string_exp,$ first_name)||”作为输入,我使用了“ teu”(不带“”),应该接受…
Any idea why this error message is appearing ? 知道为什么会出现此错误消息吗? Thank you for your help.
谢谢您的帮助。
You have to close brace here and remove the ||
您必须在此处关闭大括号并删除
||
operator. 运营商。
Also it is die()
and not died()
也是
die()
而不是die()
died()
died('Lamentamos, mas constam erros no seu registo.');
if(!isset($_POST['element_1_1']) ||
!isset($_POST['element_1_2']) ||
!isset($_POST['element_2'])){
die('Lamentamos, mas constam erros no seu registo.');
}
The message means that there is an error at character 12 in your regex. 该消息表示您的正则表达式中的字符12处有错误。 Since that is the apostrophe (single quote), my guess is that you need to escape it.
由于这是撇号(单引号),所以我想您需要将其转义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.