View Full Version : parse error, unexpected '<'

11-20-2007, 02:00 AM
I wrote some php code that produces an error and having checked over and over again I just cannot figure out what the problem is.

The error is: "parse error, unexpected '<' in blabla.php on line 143". On that line I have this:

$addedheadertext = "<p style=\"margin-left:3px;\"><img src=\"".<?php echo $mosConfig_live_site; ?>."/images/logo.gif\" border=\"0\" width=\"165\" height=\"87\" alt=\"logo\"><br><br><b>Emailing: <a href=\"".<?php echo $articlefullversionurl; ?>."\">".<?php echo $mainframe->getPageTitle(); ?>."</a> ( ".<?php echo $year; ?>." <a href=\"http://".<?php echo $mosConfig_sitename; ?>."\">".<?php echo $mosConfig_sitename; ?>."</a>)<br>Full page url: <a href=\"".<?php echo $articlefullversionurl; ?>."\">".<?php echo $articlefullversionurl; ?>."</a></b><br><br></p>";

First I thought that the use of single quotation marks was the issue so I replaced those by escaped double quotation marks but that did not help. I also checked all the dots and it seems each < has a matching >.

What have I overlooked?

11-20-2007, 02:19 AM
You have <?php ?> tags in your string.. you need to remove those and the echo function.

$string = "words " . $variable . " more words";

11-20-2007, 02:20 AM
Edit: Basically says the same as above ^^^ Two great minds with almost identical answers...

You are already in PHP mode. Remove all the <?php echo ; ?> from inside the string and just leave the variable names -

$your_string = "abc" . $variable_here . "def";

11-20-2007, 02:22 AM
Copy-cat! :p

11-20-2007, 02:26 AM
I was surprised that the code example we came up with was that similar.

11-20-2007, 08:44 AM
:) Thanks to both of you!
Like the best place to hide is in plain view this is so obvious that I never saw it!