...

View Full Version : Inserting html tags into php



XiledWeb
12-22-2006, 10:41 PM
Hi, I have a list of news items that I would like separated by a line break. Whenever I insert a <p> or a <br /> the news items all get surrounded by quotes and seperate the items by more than a line break.

Here is my php:


while ($article = mysql_fetch_array($articles)) {

$id = $article['id'];
$articletext = $article['LEFT(articletext, 120)'];

// If the article text is 120 characters long, add "..." to the end of it
// to indicate that it is actually longer. strlen() returns string length!
if (strlen($articletext) == 120) {
$articletext .= "...";
}

// Remove any custom tags (even partial ones!) in the article text. They are not needed in this preview.
$articletext = ereg_replace('\\[(B|EB|I|EI|L|L=|L=[-_./a-z0-9!&%#?+,\'=:;@~]+|EL|E)?(]|$)', '',
$articletext);

// Finally, make it safe to display in an HTML document
$articletext = htmlspecialchars($articletext);

$author = htmlspecialchars($article['name']);
$email = htmlspecialchars($article['email']);
$adate = $article['articledate'];

echo "<tr valign=\"top\">\n";
echo "<td><a href=\"article.php?id=$id\">$articletext</a></td>\n";
echo "<td><a href=\"mailto:$email\">$author</a></td>\n";
echo "<td>$adate</td>\n";
echo "</tr>\n";
}
?>

mlseim
12-23-2006, 06:09 AM
You have a line here that does just that ... it takes out HTML commands.
That's what it's supposed to do:

// Finally, make it safe to display in an HTML document
$articletext = htmlspecialchars($articletext);

Comment out that line and see what happens ... like this:

// Finally, make it safe to display in an HTML document
// $articletext = htmlspecialchars($articletext);

XiledWeb
12-23-2006, 09:02 PM
No difference...with the <p> </p> tags but I got the <br /> tags working. :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum