GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Wordpress: unexpected T_STRING error (https://gfy.com/showthread.php?t=1076603)

The Dawg 08-01-2012 09:41 AM

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?

:helpme

alcstrategy 08-01-2012 10:06 AM

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); ?>

The Dawg 08-01-2012 10:18 AM

Quote:

Originally Posted by alcstrategy (Post 19097836)
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.

The Dawg 08-01-2012 10:31 AM

If figured it out.

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

Zoxxa 08-01-2012 10:49 AM

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

Thats probably what you wanted if the path is correct.

The Dawg 08-01-2012 11:15 AM

Quote:

Originally Posted by Zoxxa (Post 19097928)
<?php include(get_post_meta($post->ID, 'galleries', true)); ?>

Thats probably what you wanted if the path is correct.

Yeap. That works too.

Thanks!

fris 08-01-2012 12:13 PM

ya you had a <?php inside a <?php ;)

alcstrategy 08-01-2012 12:52 PM

Quote:

Originally Posted by The Dawg (Post 19097789)
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?

:helpme

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

V_RocKs 08-01-2012 01:38 PM

this thread delivers


All times are GMT -7. The time now is 02:56 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc