eknudtson Posted August 29, 2006 Share Posted August 29, 2006 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? Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 29, 2006 Share Posted August 29, 2006 Post ur code so we can check Quote Link to comment Share on other sites More sharing options...
eknudtson Posted August 29, 2006 Author Share Posted August 29, 2006 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? Quote Link to comment Share on other sites More sharing options...
Clarisse Posted August 29, 2006 Share Posted August 29, 2006 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. Quote Link to comment Share on other sites More sharing options...
eknudtson Posted August 29, 2006 Author Share Posted August 29, 2006 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 Link to comment Share on other sites More sharing options...
hitman6003 Posted August 29, 2006 Share Posted August 29, 2006 What is contained in these variables for the output that is being commented out:$imageURLL$modObj->longName$data['shortname']? Quote Link to comment Share on other sites More sharing options...
Clarisse Posted August 30, 2006 Share Posted August 30, 2006 [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. Quote Link to comment Share on other sites More sharing options...
T.Stedel Posted August 31, 2006 Share Posted August 31, 2006 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 Quote Link to comment Share on other sites More sharing options...
eknudtson Posted August 31, 2006 Author Share Posted August 31, 2006 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? Quote Link to comment Share on other sites More sharing options...
eknudtson Posted August 31, 2006 Author Share Posted August 31, 2006 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.