Jump to content

Archived

This topic is now archived and is closed to further replies.

eknudtson

Strange Text Output : "<!-- -->" instead of my text when print or echo

Recommended Posts

Hey Everybody, I'm having a strange issue with my php script. I'm using a loop to put together a string, and then output that string onto the page. 90% of the time it works, but on a few of the pieces of data that are added to the string, it chokes, and instead of putting out an img tag, it outputs: <!-- -->

[code]<!-- -->[/code]

Very strange indeed. Anyone run into this in the past?

Share this post


Link to post
Share on other sites
not sure if this will help....

[code]$htmlBegin = "<div class='nbfReturnedBoards'>";
$htmlMiddle = "";
foreach($boardsArray as $data) {
$modObj = new BoardModel();
$modObj->Get($data['boardmodelid']);

$imageURLL = $imageDir."/".$modObj->shortName."_".$data['shortname'].".jpg";
$linkURLL = $boardLinkStart.$boardModel->shortName."/".$data['shortname'];

$htmlMiddle .= "<div class='nbfBoard_".$imageSize."'>";
$htmlMiddle .= $data['shortname'];
$htmlMiddle .= "<a href='".$linkURLL."'>";
$htmlMiddle .= "<img src='".$imageURLL."' alt='".$modObj->longName."_".$data['shortname']."'>";
$htmlMiddle .= "</a>";
$htmlMiddle .= "</div>";

}
$htmlEnd = "</div>";
$htmlDone = $htmlBegin.$htmlMiddle.$htmlEnd;
return $htmlDone;[/code]

and that should output something like this:

[code]<div class='nbfBoard_tinypage'>143<a href='http://www.mysite.com/en/products/boards/modelname/143'><img src='http://www.mysite.com/images/products/boards/tinypage/modelname_143.jpg' alt='Board Model Name_143'></a></div>[/code]

and it does... 90 percent of the time, but on some "Board Models" ie different data... it chokes and spits out this:

[code]<div class='nbfBoard_tinypage'>157<a href='http://www.mysite.com/en/products/boards/modelname/157'><!--                                                                                                    --></a></div>[/code]

It outputs everything EXCEPT the img tag... weird, eh?

Share this post


Link to post
Share on other sites
Just thinking but do you have a template file (.tpl) related to the file which is causing you the problems? 

I'd start looking near modelname_157.jpg  for an error/mistake that "<!--" looks like the start of an HTML hidden notation.  My guess is that there is a syntax error.

Share this post


Link to post
Share on other sites
Clarisse, no I'm not using any template files. I'm just running through a loop, spittin out text. <!-- is the start of a hidden note in html, which is why this is so strange. The syntax error can't be in PHP, because like I said, it works 90 percent of the time, and only chokes on specific data. I've looked at this data, and to me there's nothing strange about it. Just plain old text.

Are there any circumstances when php would spit out <!-- --> for a reason?

Thanks for your help...

Share this post


Link to post
Share on other sites
What is contained in these variables for the output that is being commented out:

$imageURLL
$modObj->longName
$data['shortname']

?

Share this post


Link to post
Share on other sites
[quote author=eknudtson link=topic=106091.msg424349#msg424349 date=1156894178]
Clarisse, no I'm not using any template files. I'm just running through a loop, spittin out text. <!-- is the start of a hidden note in html, which is why this is so strange. The syntax error can't be in PHP, because like I said, it works 90 percent of the time, and only chokes on specific data. I've looked at this data, and to me there's nothing strange about it. Just plain old text.

Are there any circumstances when php would spit out <!-- --> for a reason?

Thanks for your help...
[/quote]


I'm sorry but that is about all I can think that it might be.  I have never seen PHP just outputting "<!-- -->".

Try what hitman6003 is suggesting.

Good luck.

Share this post


Link to post
Share on other sites
Does any of the stuff have things similar to closing a tag, double quotes, or single quotes?

I believe I had the same problem when I was creating a php similarily (messageboard for work) and it was because I wasn't properly escaping the text.

addslashes(string)
htmlentities(string)
htmlspecialchars(string)
striptags(string) * I think

Share this post


Link to post
Share on other sites
Hittman,
you asked what these variables will have in them:
$imageURLL
$modObj->longName
$data['shortname']

all of these will be strings.
$imageURLL will have a url like this "http://www.mysite.com/images/products/boards/board.jpg"
$modObj->longName will be a string like this "My Board"
$data['shortname'] will have a string like this "my_board"

does that help any?

Share this post


Link to post
Share on other sites
addslashes(string)
htmlentities(string)
htmlspecialchars(string)
striptags(string)

there are no closing a tag, double quotes, or single quotes in my strings. I'm also escaping the strings just in case when they come out of the mysql db. In which order should I be running these functions you list above T.Stedel?

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.