PHP - Parse error, unexpected T_STRING [Solved/Closed]

Ryan - Aug 18, 2015 at 12:54 PM - Latest reply:  Ryan
- Aug 20, 2015 at 07:53 PM
Hello,

I'm having a lot of trouble with my WordPress website and it seems to be because of this: http://ccm.net/faq/595-php-parse-error-unexpected-t-string-expecting-or

I want to display a custom field which is usually accomplished by inserting this simple code:

<?php echo get_post_meta(get_the_ID(), 'custom_field_name', TRUE); ?>

...but I get an error every time. Adding back slashes stops the error but nothing is displayed.

Any advice would be greatly appreciated.

Thank you!

See more 

7 replies

ac3mark
Posts
10830
Registration date
Monday June 3, 2013
Status
Moderator
Last seen
November 13, 2018
- Aug 18, 2015 at 05:51 PM
0
Thank you
Hey there. I found this in the Wordpress man. https://wordpress.org/support/topic/need-to-add-variable-to-function


It looks like the TRUE could break it, if the syntax is csse sensitive. I do apologize for not knowing the wordpress syntax. I guess put that down on things to learn. Great more marketable skills!
I hope this helps!

Have FUN!

I have said it once, I will say it again. IT!
ac3mark
Posts
10830
Registration date
Monday June 3, 2013
Status
Moderator
Last seen
November 13, 2018
- Aug 19, 2015 at 04:43 PM
Maybe try the ASCII code for the " ' " symbol?
ac3mark
Posts
10830
Registration date
Monday June 3, 2013
Status
Moderator
Last seen
November 13, 2018
- Aug 19, 2015 at 06:55 PM
Ok, you will need to build the string quote, as in : '''

or 'Single quote''Single quote''Single quote'...Sometimes you need to emulate the string, like in ASP: Response.write("here is the string"""+"In Quotes"+"""."); The previous statement would output: here is the string "In Quotes". Give that a try!
Thanks for all of the advice buddy. Through hours and hours of trial and error, this finally worked:

'.get_post_meta($q->ID, 'price', true).'

This has been a wake up call that I need to get much stronger in PHP. Like you said, nothing wrong with more marketable skills.
ac3mark
Posts
10830
Registration date
Monday June 3, 2013
Status
Moderator
Last seen
November 13, 2018
- Aug 20, 2015 at 05:15 PM
Atta boy! Way to Go! Should we mark it Solved?