Wordpress: unexpected T_STRING error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • The Dawg
    Confirmed User
    • Apr 2002
    • 2438

    #1

    Wordpress: unexpected T_STRING error

    I have a custom field named galleries that is producing the "Parse error: syntax error, unexpected T_STRING" error.

    galleries field has the server location of a gallery ( /home/www/gallery1.php )


    If I hardcode the link in the template it works
    Code:
    <?php include('/home/www/gallery1.php'); ?>
    But...

    Code:
    <?php include('<?php echo get_post_meta($post->ID, 'galleries', true) ?>'); ?>
    ^^ ERROR ^^

    Whats wrong with this line?

  • alcstrategy
    Confirmed User
    • May 2012
    • 124

    #2
    Code:
    <?php include('<?php echo get_post_meta($post->ID, 'galleries', true) ?>'); ?>
    That code is incorrect in a few ways.

    The immediate reason you get T_STRING error is because you have single quotes within single quotes.

    Also the use of include is incorrect and unnecessary..

    Just do <?php echo get_post_meta($post->ID, 'galleries', true); ?>

    Comment

    • The Dawg
      Confirmed User
      • Apr 2002
      • 2438

      #3
      Originally posted by alcstrategy
      Code:
      <?php include('<?php echo get_post_meta($post->ID, 'galleries', true) ?>'); ?>
      That code is incorrect in a few ways.

      The immediate reason you get T_STRING error is because you have single quotes within single quotes.

      Also the use of include is incorrect and unnecessary..

      Just do <?php echo get_post_meta($post->ID, 'galleries', true); ?>
      Thanks, I didnt notice the single quote issue.

      If I use just the <?php echo get_post_meta($post->ID, 'galleries', true); ?>

      it just prints out the location of the gallery /home/www/gallery1.php

      What I'm trying to do is include a html page within the template.

      Comment

      • The Dawg
        Confirmed User
        • Apr 2002
        • 2438

        #4
        If figured it out.

        I set the custom field as a variable, then used that var in the include.

        Comment

        • Zoxxa
          Confirmed User
          • Feb 2011
          • 1026

          #5
          <?php include(get_post_meta($post->ID, 'galleries', true)); ?>

          Thats probably what you wanted if the path is correct.
          [email protected]
          ICQ: 269486444
          ZoxEmbedTube - Build unlimited "fake" tubes with this easy 100% unencoded CMS!

          Comment

          • The Dawg
            Confirmed User
            • Apr 2002
            • 2438

            #6
            Originally posted by Zoxxa
            <?php include(get_post_meta($post->ID, 'galleries', true)); ?>

            Thats probably what you wanted if the path is correct.
            Yeap. That works too.

            Thanks!

            Comment

            • fris
              Too lazy to set a custom title
              • Aug 2002
              • 55679

              #7
              ya you had a <?php inside a <?php ;)
              Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

              Comment

              • alcstrategy
                Confirmed User
                • May 2012
                • 124

                #8
                Originally posted by The Dawg
                I have a custom field named galleries that is producing the "Parse error: syntax error, unexpected T_STRING" error.

                galleries field has the server location of a gallery ( /home/www/gallery1.php )


                If I hardcode the link in the template it works
                Code:
                <?php include('/home/www/gallery1.php'); ?>
                But...

                Code:
                <?php include('<?php echo get_post_meta($post->ID, 'galleries', true) ?>'); ?>
                ^^ ERROR ^^

                Whats wrong with this line?

                sorry i totally overlooked what you were actually doing and just focused on the code i saw, my apologies

                Comment

                • V_RocKs
                  Damn Right I Kiss Ass!
                  • Nov 2003
                  • 32449

                  #9
                  this thread delivers

                  Comment

                  Working...