tags:

views:

27

answers:

1

Ok, here is something strange that has had me stumped for about 45 minutes...

I have a custom .tpl.php file that I am using to theme a node view. I have plenty of PHP already functioning in this template, but today I had a couple of CCK fields I wanted to move around.

However, when I add my snippet in, I get "Parse error: syntax error, unexpected '['"

<?php print $node->field-account-status[0]['value']; ?>

The thing is, this is a fairly common snippet and should function. Examples of it are used here http://groups.drupal.org/node/25064

Here is the same snippet showing PHP above and below it, both working..Why is this snippet throwing this error???

<h2>Service Requests for <?php print $node->title; ?>  </h2>

//lines above and below this one are working PHP
<?php print $node->field-account-status[0]['value']; ?>

<?php
$i = 0;
print '<table class="views-account-sr">';
+6  A: 

The problem is that you are using - in a variable name. - is not valid in any PHP identifier. - is the subtraction operator.

You probably meant to use _:

<?php print $node->field_account_status[0]['value']; ?>
Ben James
Valid variable name structure: http://www.php.net/manual/en/language.variables.basics.php
Felix Kling
Thanks Ben - your are 100% right. I knew I was wrong, but I starred at that line for nearly an hour. I don't know who up voted my post - I deserve a punch in the face for this bogus syntax question.. :)
cinqoTimo