Grow your CSS skills. Land your dream job.

unexpected T_ELSE

  • # February 8, 2012 at 9:15 am

    Im getting an unexpected T_ELSE and I cant figure it out. Any help appreciated.

    < ?php if((get_post_meta($post->ID, "video", true))) { ?>
    < ?php echo get_post_meta($post->ID, "video", true); ?>
    < ?php } ?>

    < ?php else if((get_post_meta($post->ID, "image", true))) { ?>
    < ?php
    $images = array(
    $image = $images[array_rand($images)];
    $output = "";
    echo $output;
    < ?php } ?>
    # February 8, 2012 at 10:57 am

    $image = $images[array_rand($images)];

    only needs to be

    $image = array_rand($images);

    # February 8, 2012 at 11:01 am

    still getting same error.

    # February 8, 2012 at 12:18 pm

    Is this the only code? It seems like your if/else statement is being broken. Is there additional code or hidden characters between the close of the if and the start of the else if statement?

    Can you remove the php tags and seemingly blank line that separate them so you end up with } else if { to see if that fixes it?

    # February 8, 2012 at 12:21 pm

    Other then some divs for styling. That is it. and I tried you suggestion on the $image, but it did not work. Thanks for taking the time to look at it. For now, I just changed the “else if” to an “if”.

    # February 9, 2012 at 1:45 am

    That’s because I’m pretty sure it’s ‘elseif’, not ‘else if’. I’m a PHP noob, though!

    # February 9, 2012 at 8:41 am

    You would be correct unless you use curly brackets which I did. But elseif is the correct format. :)

    What I read

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".