Good code getting parsed incorrectly....

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Citizen
Forum Contributor
Posts: 300
Joined: Wed Jul 20, 2005 10:23 am

Good code getting parsed incorrectly....

Post by Citizen »

I have a script that allows users to put in their own articles. The problem is that sometimes users put in bad code and the out put ends up looking like this:

I think it has something to do with the image tag not being closed correctly after the "alt" property.

Any ideas what I need to do to the $content variable before echoing it to prevent this from happening?

Code: Select all

<td width="100%">
 							<div style="margin-left: 1%; margin-top: 2%; margin-bottom: 2%;">
 							<span style="font-size: 10pt;">
 							<p><img bigimg="" src="http://static.ibnlive.com/pix/sitepix/09_2006/knot_248.jpg" alt="WHERE IS THE LOVE: The wife’s message read - You are the most despicable, deceitful people I have ever met." title="WHERE IS THE LOVE: The wife&r... <a href='article.php?article=65'>(More)</a>
 							</span>
 							</div>
 						</td>
 					</tr>
 					<tr>
 						<td>
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Somewhere something like htmlentities() is applied incorrectly ...maybe ;)
Citizen
Forum Contributor
Posts: 300
Joined: Wed Jul 20, 2005 10:23 am

Post by Citizen »

volka wrote:Somewhere something like htmlentities() is applied incorrectly ...maybe ;)
When I use htmlentities, the HTML no longer works....

Here is an example:

http://www.hashbush.com/newsindex.php
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

I didn't say you should add another call to htmlentities(), did I? I just speculated that something like htmlentities already has been used incorrectly.
But without seeing the actual code it's all wild guessing.
Citizen
Forum Contributor
Posts: 300
Joined: Wed Jul 20, 2005 10:23 am

Post by Citizen »

I found the problem.... it has to do with substr cutting my <img code in half.

I posted a more relevent thread since I was wrong in assuming it was a parse error:

viewtopic.php?t=60683
Post Reply