phpparsing-error

php Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING


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


Solution

  • 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