doucuodan0897 2012-01-28 06:17
浏览 36
已采纳

php preg_match - 编译失败

was wondering if someone could help with this one. This is the first time I've seen this error.

Warning: preg_match() [function.preg-match]: Compilation failed: nothing to repeat at offset 9

which is inrelation to this part of my code:

( isset( $_POST[$post_key] ) && $misc[2] === true && ! preg_match( $misc[0], $_POST[$post_key] ) ) 

and my full (bit thats relevant) piece of code is below.

The data sent over is as follows:

ajax-request    true
author          1
epi             2
jbid            781711001327010590
message         dfdf
type            send-invite

Anyone know any reason for this or what causes the error?

case 'send-invite' :

    if( free_member_is_logged_in() ) {

        $post_array = array(
            'message' => array(
                '#^.*{3,500}$#is',
                '<p class="error_message">Please enter a message between 3 and 500 characters.</p>',
                true
            ),
            'epi' => array(
                '#^[0-9]+$#is',
                '<p class="error_message">An internal error has occured. If this problem persists please contact support</p>',
                true
            ),
            'author' => array(
                '#^[0-9]+$#is',
                '<p class="error_message">An internal error has occured. If this problem persists please contact support.</p>',
                true
            ),
            'jbid' => array(
                '#^[0-9]+$#is',
                '<p class="error_message">Please specify a job which you have published.</p>',
                true
            )
        );

        $continue = true;

        foreach( $post_array as $post_key => $misc ) {
            if( 
                    ( ! isset( $_POST[$post_key] ) && $misc[2] === true ) 
                || 
                    ( isset( $_POST[$post_key] ) && $misc[2] === true && ! preg_match( $misc[0], $_POST[$post_key] ) ) 
                || 
                    ( isset( $_POST[$post_key] ) && $misc[2] === false && $_POST[$post_key] != '' && ! preg_match( $misc[0], $_POST[$post_key] ) ) 
            ) {

                $continue = false;
                $error_message = $misc[1];

            }
            ${cleankey($post_key)} = res($_POST[$post_key]);
        }
  • 写回答

2条回答 默认 最新

  • douwulu2576 2012-01-28 06:22
    关注

    Same as here I guess - you can't use *{} together:

    Warning: preg_match() [function.preg-match]: Compilation failed: nothing to repeat at offset

    $post_array = array(
            'message' => array(
                '#^.*{3,500}$#is',
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 python:excel数据写入多个对应word文档
  • ¥60 全一数分解素因子和素数循环节位数
  • ¥15 ffmpeg如何安装到虚拟环境
  • ¥188 寻找能做王者评分提取的
  • ¥15 matlab用simulink求解一个二阶微分方程,要求截图
  • ¥30 乘子法解约束最优化问题的matlab代码文件,最好有matlab代码文件
  • ¥15 写论文,需要数据支撑
  • ¥15 identifier of an instance of 类 was altered from xx to xx错误
  • ¥100 反编译微信小游戏求指导
  • ¥15 docker模式webrtc-streamer 无法播放公网rtsp