2012-01-28 215 views
0

想知道是否有人可以幫助這個。這是我第一次看到這個錯誤。php pregmatch - 編譯失敗

警告:的preg_match()[function.preg匹配]:編譯 失敗:在沒有任何偏移9

這是inrelation到我的這部分代碼重複:

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

和我的完整(有點相關)一段代碼如下。

發送過來的數據如下:

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

任何人都知道任何原因或什麼原因造成的錯誤?

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]); 
     } 

回答

1

3首500個字符

之間的消息正則表達式#^.{3,500}$#is就好了。

+0

感謝您的幫助,抱歉沒有刷新頁面,所以下面的答案讓我得出您的結論。無論如何,歡呼聲 – 2012-01-28 06:33:07