2014-02-05 3 views
-2

Я получаю эту ошибку:Анализировать ошибка: неожиданный T_STRING

Parse error: syntax error, unexpected T_STRING in ...contact_us.php on line 49.

Может кто-то помочь мне понять, как это исправить?

<?php 
/** 
* Template Name: Contact Template 
* The Contact Template file 
* 
* @package WordPress 
* @subpackage Invictus 
* @since Invictus 1.0 
*/ 
wp_reset_query(); 

wp_enqueue_script('validation'); 

get_header(); 

    if(isset($_POST['button_contact_submit'])){ 

     // store some values 
     $email = $_POST['contact_email']; 
     $to = get_option_max('contact_email'); 
     $message = stripslashes($_POST['contact_message']); 
     $content_type="text/plain"; 

     // Clean the from data 
     $from_array = preg_split("/[rn]+/is",trim($_POST['contact_name']),-1,PREG_SPLIT_NO_EMPTY); 
     $from = $from_array[0]; 

     // smtp secure settings 
     @ini_set("SMTP", $to); 
     @ini_set("smtp_port", 25); 
     @ini_set('sendmail_from', $email); 

     // build the message 
     $msg = "{$from} ({$email}) has sent you a contact request.rn"; 
     $msg .= "-----------------------------------------------------rnrn"; 
     $msg .= "{$message}rn"; 

     // build the subject 
     $subject = "[Contact Request] From ".$_POST['contact_name']; 

     // build the headers 
     $headers = 'MIME-Version: 1.0' . "rn"; 
     $headers .= 'Content-type: ' . $content_type . '; charset=UTF-8' . " rn"; 
     $headers .= 'From: ' . $_POST['contact_name'] . " <".$_POST['contact_email'].">rn"; 
     $headers .= 'X-Mailer: PHP/' . phpversion(); 
     $headers .= 'Reply-To: '.$email."rn"; 

    if(wp_mail(get_option_max('contact_email'), $subject, $msg, $headers)){ 
      $resultOk = "<div class="alert"><p class="success"><strong>". __("Your message has been sent</strong>. Thank you for your request!", MAX_SHORTNAME)."</p></div>"; 
     }else{ 
      $resultError = "<div class="alert"><p class="error">". __("Message delivery failed! Please try again.", MAX_SHORTNAME) ."</p></div>"; 
     } 

    } 


?> 

<div id="primary" class="template-fullsize"> 

     <header <?php post_class('entry-header'); ?> id="post-<?php the_ID(); ?>" > 

      <h1 class="page-title"><?php the_title() ?></h1> 

      <?php 
      // check if there is a excerpt 
      if(max_get_the_excerpt()){ 
      ?> 
      <h2 class="page-description"><?php max_get_the_excerpt(true) ?></h2> 
      <?php } ?> 

     </header> 

     <div id="content" role="main" class="clearfix"> 

      <?php the_content() ?> 

      <div class="clearfix"> 

       <?php 
       // Display Infotext if enabled 
       if(get_option_max('contact_show_text') == "true") { 
        $class_1 = "col_2"; 
        if(get_option_max('contact_show_info') == 'true'){ 
         $class_1 = "col_one_third"; 
        } 
       ?> 
       <div class="<?php echo $class_1 ?>"> 
        <h3><?php stripslashes(get_option_max('contact_sidebar_header',true))?></h3> 
        <p><?php echo stripslashes(get_option_max('contact_info')) ?></p> 
       </div> 
       <?php } ?> 

       <?php 
        // Display Company Infos if enabled 
        if(get_option_max('contact_show_info') == "true") { 
         $class_2 = "col_2"; 
         if(get_option_max('contact_show_info') == 'true'){ 
          $class_2 = "col_one_third"; 
         } 
       ?> 
       <div class="<?php echo $class_2 ?>"> 
        <h3><?php stripslashes(get_option_max('contact_info_header',true))?></h3> 
        <ul> 
         <?php if (get_option_max('contact_adress_1') != "") echo '<li>'. get_option_max('contact_adress_1') . '</li>' ?> 
         <?php if (get_option_max('contact_adress_2') != "") echo '<li>'. get_option_max('contact_adress_2') . '</li>' ?> 
         <?php if (get_option_max('contact_phone') != "") echo '<li>'. __('Phone', MAX_SHORTNAME) . ': '. get_option_max('contact_phone') . '</li>' ?> 
         <?php if (get_option_max('contact_fax') != "") echo '<li>'. __('Fax', MAX_SHORTNAME) . ': '. get_option_max('contact_fax') . '</li>' ?> 
         <?php if (get_option_max('contact_info_email') != "") echo '<li>'. __('eMail', MAX_SHORTNAME) . ': <a href="mailto:' . get_option_max('contact_info_email') . '">'. get_option_max('contact_info_email') . '</a></li>' ?> 
        </ul> 
       </div> 
       <?php } ?> 


       <?php $class_3 = "col_one_third col_one_third_last"; ?> 
       <div class="<?php echo $class_3 ?>"> 
       <?php if(!isset($resultOk)){ ?> 
        <?php 
         if(isset($resultError)){ 
          echo($resultError); 
         } 
        ?> 
         <form id="contactForm" action="<?php $_SERVER['PHP_SELF']?>" method="post"> 
          <ul> 
           <li> 
            <label><?php _e("Your Name", MAX_SHORTNAME) ?>: <span class="required">*</span></label> 
            <input name="contact_name" type="text" class="required requiredField" /> 
           </li> 
           <li> 
            <label><?php _e("Your eMail", MAX_SHORTNAME) ?>: <span class="required">*</span></label> 
            <input name="contact_email" type="text" class="required requiredField email" /> 
           </li> 
           <li> 
            <label><?php _e("Your Message", MAX_SHORTNAME) ?>: <span class="required">*</span></label> 
            <textarea name="contact_message" cols="50" rows="5" class="required requiredField "></textarea> 
           </li> 
           <li><button type="submit" name="button_contact_submit"><?php _e("Send Message", MAX_SHORTNAME) ?></button></li> 
          </ul> 
          <p><small><em>(*) <?php _e("Required Fields", MAX_SHORTNAME) ?></em></small></p> 
         </form> 
       <?php } ?> 
       <?php 
        if(isset($resultOk)){ 
         echo($resultOk); 
        } 
       ?> 
       </div> 
      </div> 

     </div><!-- #content --> 
    </div><!-- #primary --> 
+0

Лучше всего, чтобы выяснить, какая линия является один сообщается в сообщении об ошибке и Расскажи нам. По моему счету, который может быть неправильным, это строка, начинающаяся с '$ resultOk ='. У этой строки есть куча unescaped '' 'в вашей строке HTML, которая преждевременно закрывает вашу строку и ошибочно открывает новые строки для PHP, что, вероятно, является причиной вашей ошибки. Линия' $ resultError = 'имеет ту же проблему. – ajp15243

ответ

1
if(wp_mail(get_option_max('contact_email'), $subject, $msg, $headers)){ 
     $resultOk = "<div class="alert"><p class="success"><strong>". __("Your message has been sent</strong>. Thank you for your request!", MAX_SHORTNAME)."</p></div>"; 
    }else{ 
     $resultError = "<div class="alert"><p class="error">". __("Message delivery failed! Please try again.", MAX_SHORTNAME) ."</p></div>"; 
    } 

} 

Вы используете двойные кавычки, не избежать их, вы можете избежать их с помощью обратной косой черты или заменить двойные кавычки одинарные кавычки

Изменить это:

if(wp_mail(get_option_max('contact_email'), $subject, $msg, $headers)){ 
     $resultOk = '<div class="alert"><p class="success"><strong>'. __("Your message has been sent</strong>. Thank you for your request!", MAX_SHORTNAME)."</p></div>"; 
    }else{ 
     $resultError = '<div class="alert"><p class="error">'. __("Message delivery failed! Please try again.", MAX_SHORTNAME) ."</p></div>"; 
    } 

} 
+0

есть, извините. Опечатка. – Ali

0

Ошибка здесь

<div class="alert"><p class="success"> 

Это должно быть, как это

<div class='alert'><p class='success'> 

двойных qoutes на одиночные qoutes

Я надеюсь, что это позволит решить проблему

Смежные вопросы