dpwgzi7987 2013-11-09 16:10
浏览 54

编译失败:偏移量为12的字符类中的范围乱序

I have a very basic HTML form with text boxes defined as

<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

// 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"

Line 45 is "if(!preg_match($string_exp,$first_name) ||" As input I used "teu" (without "") which should be accepted…

Any idea why this error message is appearing ? Thank you for your help.

  • 写回答

2条回答 默认 最新

  • dtjw6660 2013-11-09 16:14
    关注

    You have to close brace here and remove the || operator.

    Also it is die() and not died()

    died('Lamentamos, mas constam erros no seu registo.'); 
    

    Putting it all together

    if(!isset($_POST['element_1_1']) ||
        !isset($_POST['element_1_2']) ||
        !isset($_POST['element_2'])){
        die('Lamentamos, mas constam erros no seu registo.');
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用