Jump to content


Photo

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


  • Please log in to reply
9 replies to this topic

#1 eknudtson

eknudtson
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 29 August 2006 - 02:51 PM

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: <!-- -->

<!-- -->

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


#2 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 29 August 2006 - 02:58 PM

Post ur code so we can check
Tell me the problem, I will try tell you the solution

#3 eknudtson

eknudtson
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 29 August 2006 - 03:58 PM

not sure if this will help....

$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;

and that should output something like this:

<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>

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

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

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

#4 Clarisse

Clarisse
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 29 August 2006 - 09:20 PM

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.

#5 eknudtson

eknudtson
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 29 August 2006 - 11:29 PM

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...

#6 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 29 August 2006 - 11:32 PM

What is contained in these variables for the output that is being commented out:

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

?


#7 Clarisse

Clarisse
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 30 August 2006 - 09:33 PM

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...



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.

#8 T.Stedel

T.Stedel
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 31 August 2006 - 01:26 AM

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

#9 eknudtson

eknudtson
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 31 August 2006 - 12:49 PM

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.co...ards/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?


#10 eknudtson

eknudtson
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 31 August 2006 - 10:25 PM

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?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users