This question already has an answer here:

New to PHP. Having a problem with a "Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING"

Here is the code:

<?php 
$moreLink = '';
if ($data->node_type == "product_book") :
$path = str_replace(' ', '-', strtolower($data->node_title));
$moreLink = '<a href="/books/'.$path'">Read more > </a>';
else :
$path = drupal_get_path_alias( 'node/' . $data->nid);
$moreLink = '<a href="/'.$path.'">Read more > </a>';
endif;
return $moreLink;
?>

Any help would be greatly appreciated. Thanks. -Matt

share|improve this question

marked as duplicate by John Conde, deceze, Joe, cale_b, Sergiu Paraschiv May 1 '14 at 15:26

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
@JohnConde In fact the reference question does not include this particular error (with T_CONSTANT_ENCAPSED_STRING) – h2ooooooo May 1 '14 at 14:45
    
@h2ooooooo Really? I'm surprised. Maybe we need to add this question to it? Or find another one to be the canonical answer for it? – John Conde May 1 '14 at 14:47
    
@JohnConde Technically you can click Parse error: syntax error, unexpected T_XXX, then PHP Parse/Syntax Errors; and How to solve them? and then Unexpected T_CONSTANT_AND_ENCAPSED. Perhaps we should just add this to the reference question. – h2ooooooo May 1 '14 at 14:49
    
@h2ooooooo Yeah. I'd like to see this specific error message listed in the TOC in the question. It would be a lot easier to find IMHO. – John Conde May 1 '14 at 14:50
    
@JohnConde What's the norm on SO for this sort of reference? All the answers seem to be part of the question. Are "external" (link to an answer on other question) OK, or should there be an answer added with a link to the specific "external" answer? – h2ooooooo May 1 '14 at 14:52
up vote 1 down vote accepted

You forget a . on this line:

$moreLink = '<a href="/books/'.$path'">Read more > </a>';

It should be

$moreLink = '<a href="/books/'.$path.'">Read more > </a>';
                                    ^ here
share|improve this answer
    
Thanks! Worked perfectly. – user3593061 May 1 '14 at 14:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.