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
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>');
        
        }
        ?>

Link to comment
Share on other sites

<?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.

Link to comment
Share on other sites

  • 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}/>

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.