LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   PHP "Expecting `T_STRING'...", and it's driving me nuts (https://www.linuxquestions.org/questions/programming-9/php-expecting-%60t_string-and-its-driving-me-nuts-379578/)

rose_bud4201 11-03-2005 09:27 AM

PHP "Expecting `T_STRING'...", and it's driving me nuts
 
Can someone please help me find out what's wrong with this code? It's in the middle of a web page, so I'll pull out everything around it.

Code:

  echo <<< END
    <BR>
    <BR><CENTER><DIV STYLE="font-family: tahoma; font-size: 10px">
      <<<-- <a href="http://www.website.com/index_test.php?skip=$goBack">Go Earlier?</a> | <a href="http://www.website.com/index_test.php?skip=$goForward">Go Later?</a> -->>><BR><BR><a href="mailto:admin@website.com">Contact?</a>
    </DIV></CENTER><BR>
END;
} // Ends if-else

mysql_close($connection);
?>
        <!--        </div></DIV> -->
          </TD>
          </TR>
          </TABLE>
    </TD>
    <TD VALIGN="TOP" WIDTH="20%">
        <TABLE>
            <TR>
              <TD>
                        <!-- Top right-hand box -->
                        <DIV align="center"><div style="text-align:left; padding:5px; background-color:#ae4a48; border:1px solid black; font-size:12px; color:#000000; width:150px; font-family:verdana; font-size:10">
<?
          if($_SESSION['CurrentUserID'] == 'true') {
          print ("<CENTER>You are logged in as<BR><a href=\"" . $_SESSION['CurrentUserID'] . "\">" . $_SESSION['ShortUserID'] . "</a> (<a href=\"http://www.cybermenology.com/logout.php\">log out?</a>)</CENTER>");
        } else {
          print ("<CENTER>You are not <a href=\"http://www.cybermenology.com/login.php\">logged in</a></CENTER>");
        }
?>
                  </DIV><BR>
                  <DIV align="center"><div style="text-align:left; padding:5px; background-color:#ae4a48; border:1px solid black; font-size:12px; color:#000000; width:150px; font-family:verdana; font-size:10">

I keep getting the message "Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /var/www/html/index.php on line 306", and I can't for the life of me see what's wrong with that line! I've moved it down a few lines in the file, just to verify that it's the correct line#, and it is... Please, what am I missing?
(I have the call to session_start() up at the top of the file, and there's around 300 other lines of php code which use session variables just fine before hitting this one.)

This is driving my absolutely nuts... :(

paulsm4 11-03-2005 09:32 AM

Hi -

Try modifying your php.ini file, and make sure "register globals" is enabled:

http://us2.php.net/register_globals

rose_bud4201 11-03-2005 10:19 AM

Unfortunately, it is:

; You should do your best to write your scripts so that they do not require
; register_globals to be on; Using form variables as globals can easily lead
; to possible security problems, if the code is not very well thought of.
register_globals = On

What makes this weird is there's nothing wrong with that line, and I've used that same variable previously in the file...if the syntax parser was going to have a problem with it, why pick a later occurrance of it?

paulsm4 11-03-2005 11:08 AM

Make sure the quotes match and every line has a semicolon.

One thing that helps debugging is to save a complicated expression to a variable, then "print" (or "echo") the variable.
Code:

EXAMPLE:
  // Original
  print ("something " . $adverb asdflkjadfkljakl "\" ...;

  // Debugging tip: save to variable, check variable
  $s = "something " . $adverb asdflkjadfkljakl "\" ...;
  print ("<<" . $s . ">>\n");


rose_bud4201 11-03-2005 01:36 PM

Well....I fooled around with it a bit, moved some of the more complex and hard-to-read expressions into variables, deleted some stuff and put it back in...in short, I have no idea what I did, but somehow it works again.

Many thanks!!


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