treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Parse error: syntax error, unexpected '/' ----> i tried ... but still there is an error


  • hi guys ...
    i am working on wordpress theme , and i had some error here ..



    i working on comment form , and i would to put a text ( label ) after the input boxes .
    i tried many times but still there is error ..


    <?php comment_form(
    array(
    array(
    'author' => '<p class="comment-form-author">' . ( $req ? '<span class="required">*</span>' : '' ) .
    '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
    'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
    '<input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
    'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label>' .
    '<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>',
    ),
    'comment_notes_after' => '',
    'comment_field' => '<p class="comment-form-comment"><label for="comment">'. '</label><textarea id="comment" name="comment" aria-required="true"></textarea></p>'

    ));


    there is error here between line 1 to 10 ...

    the error :

    Parse error: syntax error, unexpected '/'




    # another questions :
    1- how can i give the box a default value ...? like (your name - your email ...etc ) instead of put < labels > before or after boxes ..
    2- the < textarea > , i want to make it not sizable .. because it make a distortion ..
  • Real question: The last item in the one array 'url' ends with a comma, try removing that.

    #another questions:
    1-
    <input type="text" value="placeholder" />
    <!-- or -->
    <input type="text" placeholder="placeholder" />

    2-Add this to your css:
    textarea {
    resize: none;
    }
  • for your 1st answer , another error appeared ..
    this is my comment.php file that work on it :

    <?php
    /**
    * @package WordPress
    * @
    */
    ?>

    <div id="commentreplycontainer">
    <?php if ( post_password_required() ) : ?>
    <div class="must-log-in"><?php _e( 'هذه التدوينة محمية ، أدخل كلمة المرور لمشاهدة هذه التدوينة' ); ?></div>
    </div><!--END commentreplycontainer -->
    <?php
    /* Stop the rest of comments.php from being processed,
    * but don't kill the script entirely -- we still have
    * to fully load the template.
    */
    return;
    endif;
    ?>

    <?php
    // You can start editing here -- including this comment!
    ?>
    <?php if ( have_comments() ) : ?>
    <div id="commentscontainertitle">
    <h2>التعليقات على هذه التدوينة : <?php comments_number( '0', '1', '%' ); ?></h2>
    </div>

    <ol class="replycomment">
    <?php wp_list_comments( array( 'callback' => 'athoob_comment' ) ); ?>
    </ol>


    <?php else : // this is displayed if there are no comments so far ?>

    <?php if ( comments_open() ) : // If comments are open, but there are no comments ?>

    <?php else : // or, if we don't have comments:

    /* If there are no comments and comments are closed,
    * let's leave a little note, shall we?
    * But only on posts! We don't want the note on pages.
    */
    if ( ! comments_open() && ! is_page() ) :
    ?>
    <p class="must-log-in"><?php _e( 'التعليقات مغلقة' ); ?></p>
    <?php endif; // end ! comments_open() && ! is_page() ?>
    <?php endif; ?>

    <?php endif; ?>


    <?php $comment_args = array(
    'fields' => apply_filters( 'comment_form_default_fields', array(
    'author' => '<p class="comment-form-author">' . ( $req ? '<span class="required">*</span>' : '' ) .
    '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
    'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
    '<input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
    'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label>' .
    '<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>'
    ),
    'logged_in_as' => '<p class="logged-in-as">' . sprintf( __( 'أنت مسجل باسم <a href="%1$s">%2$s</a>. <a href="%3$s" title="">خروج</a>' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',
    'comment_notes_after' => '',
    'comment_field' => '<p class="comment-form-comment"><label for="comment">'. '</label><textarea id="comment" name="comment" aria-required="true"></textarea></p>'

    );
    ?>
    <?php comment_form($comment_args);?>
    ?>
    </div><!--END commentreplycontainer->


    the error is :

    Parse error: syntax error, unexpected T_DOUBLE_ARROW in C:\xampp\htdocs\word\wp-content\themes\3thoob\comments.php on line 62


    please guys , i am tired , i dont know what is this wrong ,,,,,,
    -------------------------------------------------------------

    for the default value , look at this image and i think u got what i meant.
  • This is line 62:
    'logged_in_as'             => '<p class="logged-in-as">' . sprintf( __( 'أنت مسجل باسم  <a href="%1$s">%2$s</a>. <a href="%3$s" title="">خروج</a>' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',

    I wonder if it's not liking the language? Try replacing the above with this:
    'logged_in_as'             => '<p class="logged-in-as">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( ) ) ) ) . '</p>',

    If that works, then you know it's something that you've changed that isn't working.
  • still error in line 62
  • You have 33 open brackets but only 32 closed brackets. Something isn't being closed.
  • i cant find it ....
  • Here:
    <?php $comment_args = array(
    'fields' => apply_filters( 'comment_form_default_fields', array(
    'author' => '<p class="comment-form-author">' . ( $req ? '<span class="required">*</span>' : '' ) .
    '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
    'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
    '<input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
    'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label>' .
    '<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>'
    ),
    'logged_in_as' => '<p class="logged-in-as">' . sprintf( __( 'أنت مسجل باسم <a href="%1$s">%2$s</a>. <a href="%3$s" title="">خروج</a>' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',
    'comment_notes_after' => '',
    'comment_field' => '<p class="comment-form-comment"><label for="comment">'. '</label><textarea id="comment" name="comment" aria-required="true"></textarea></p>'

    ); // THIS IS CLOSING YOUR APPLY_FILTERS, NOT THE ARRAY
  • in addition, you have some indices with associative keys, and others with only values. is that intentional? I would also recommend formatting/indenting your code to make it easier to find mistakes like this.