Jump to content

Not display line breaks


your.syndrome

Recommended Posts

Hi, I've got a comments form on my site. I've tried creating line breaks in my textarea box which then gets sent to the SQL, I've looked in the SQL and it is displaying in phpmyadmin that the line breaks are there.

 

But when they get selected back to the page to be displayed it doesn't post the <br> tags or \n. I've viewed the source and the breaks are there in the white space just no HTML tags. :(

 

Any help? Ask what bits of code you might need to see and i'll post them straight away

Link to comment
https://forums.phpfreaks.com/topic/135355-not-display-line-breaks/
Share on other sites

Thanks for the reply. I have been searching around and tried to implement that but couldnt get it to work

 

This is the code I'm using to retrieve the 'posts'

 

<?
        while ($row = mysql_fetch_array($result)) {
        
            $ename = stripslashes($row['name']);
            $eemail = stripslashes($row['email']);
            $epost = stripslashes($row['post']);
            
            $grav_url = "http://www.gravatar.com/avatar.php?gravatar_id=".md5(strtolower($eemail))."&default=".urlencode($default)."&size=70"; 		 
            echo('<li><div class="meta"><img src="'.$grav_url.'" alt="Gravatar" /><p>'.$ename.'</p></div><div class="shout"><p>'.$epost.'</p></div></li>');
        
        }
        ?>

<?php
        while ($row = mysql_fetch_array($result)) {
       
            $ename = stripslashes($row['name']);
            $eemail = stripslashes($row['email']);
            $epost = nl2br(stripslashes($row['post']));
           
            $grav_url = "http://www.gravatar.com/avatar.php?gravatar_id=".md5(strtolower($eemail))."&default=".urlencode($default)."&size=70";       
            echo('<li><div class="meta"><img src="'.$grav_url.'" alt="Gravatar" /><p>'.$ename.'</p></div><div class="shout"><p>'.$epost.'</p></div></li>');
       
        }
        ?>

 

While I look at the code, a rule of thumb is you should never stripslashes on data coming out of database. You should also escape data with mysql_real_escape_string that is going into the DB.

 

Anyhow that should work.

  • 2 months later...

some body of you guys can help me in this crack.... i just want to add a defoult avatar img if this search can get any result. this is a smarty code but its break.

 

<img border="0" {if $resultsRow.user_id==''} src='{$base_url}application/images/default_avatar_thumb.jpg' {else} src='{$base_url}/application/content/profiles/{$resultsRow.user_id}_medium.jpg' {/if}/>

 

some body of you guys can help me in this crack.... i just want to add a defoult avatar img if this search can get any result. this is a smarty code but its break.

 

<img border="0" {if $resultsRow.user_id==''} src='{$base_url}application/images/default_avatar_thumb.jpg' {else} src='{$base_url}/application/content/profiles/{$resultsRow.user_id}_medium.jpg' {/if}/>

 

 

Don't hijack, create your own thread. It should be created in the 3rd party forum as well.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.