Jump to content

Search the Community

Showing results for tags 'nl2br'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Hi All, I am facing an issue I cannot solve and I just do not understand why. In a db table, I've got a field that contains text coming from a textarea in a form. If the user had entered breaklines to divide their text into paragraphs, the breaklines are replaced with "\r\n" strings, so the text in the table field may look like "Hello\r\nHow are you?". This works. Now, assuming that the user wishes to edit that text, I want to retreive that text into a textarea, with the same paragraph layout as that initially used by the user. Here is my code (without the whole db error checking code) : $link = @mysql_connect('localhost', 'root', ''); mysql_select_db('mydb', $link); $sql = 'SELECT * FROM table_name Where field_id="31"'; $rs = mysql_query($sql, $link); $arr = mysql_fetch_array($rs); $txt =$arr['user_input']; $txt = nl2br($txt); echo '<br />retrieved text from db is ' .$txt.'<br />';//Will display "retrieved text from db is Hello\r\nHow are you?" $txt=str_replace("<br />", "", $txt); echo '<br /><textarea name="text" cols="100" rows="15" >'.$txt.'</textarea>';// Will display "Hello\r\nHow are you?" in the textarea Now if manually set a variable called "Hello\r\nHow are you?". The following code $string = "Hello\r\nHow are you?"; $string=nl2br($string); $string=str_replace("<br />", "", $string); echo '<br /><textarea name="text2" cols="100" rows="15" >'.$string.'</textarea>'; Will generate "Hello How are you?" in the textarea. Why can't I manage to make this work with the text retreived from the database ? Thanks for your help. Phd
×
×
  • 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.