June 12, 201016 yr I'm currently developing a blog and on the homepage I have it so that it pulls in extracts from each post so that the reader must visit the post page. I've got it so that it displays the extract but for some reason it also displays the HTML tags for example if I put <br> in the text it doesn't just add the break. It also displays the tag. Check out the image below to see what I mean. Any help with this problem is seriously appreciated. I did find a certain tool called HTML Purifier but I'm unsure how I am to implement it. Here's my homepage code currently: <html> <head> <title>Ultan Casey | Web Designer, Technology Entusiast, Music Lover!</title> <link rel="stylesheet" href="css/style.css" type="text/css" /> </head> <body> <div class="wrapper"> <div id="upperbar"> <a href="#">Home</a> <a href="#">About Me</a> <a href="#">Contact Me</a> <a href="http://www.twitter.com/UltanKC">Twitter</a> <form id="search-form" action="/search" method="get"> <input type="text" id="textarea" size="33" name="q" value=""/> <input type="submit" id="submit" value="Search"/> </form> </div> <div id="banner"> <img src="images/banner.jpg"> </div> <div class="sidebar"></div> <div class="posts"> <?php mysql_connect ('localhost', 'root', 'root') ; mysql_select_db ('tmlblog'); $sql = "SELECT * FROM php_blog ORDER BY timestamp DESC LIMIT 5"; $result = mysql_query($sql) or print ("Can't select entries from table php_blog.<br />" . $sql . "<br />" . mysql_error()); while($row = mysql_fetch_array($result)) { $date = date("l F d Y", $row['timestamp']); $title = stripslashes($row['title']); $entry = stripslashes($row['entry']); $id = $row['id']; ?> <?php echo "<p id='title'><strong><a href=\"post.php?id=". $id . "\">" . $title . "</a></strong></p>"; ?><br /> <div class="post-thumb"><img src="thumbs/<?php echo $id ?>.png"></div> <?php echo nl2br(htmlspecialchars(substr($entry, 0, 1050))) ?>... <br> <hr><br /> Posted on <?php echo $date; ?> </p> </div> </div> </p <?php } ?> </div> </div> </div> </body> </html>
June 12, 201016 yr Change <?php echo nl2br(htmlspecialchars(substr($entry, 0, 1050))) ?> to <?php echo nl2br(substr($entry, 0, 1050)) ?>
June 12, 201016 yr Author Change <?php echo nl2br(htmlspecialchars(substr($entry, 0, 1050))) ?> to <?php echo nl2br(substr($entry, 0, 1050)) ?> I have to say that you are just awesome! Thanks for the help!
Create an account or sign in to comment