CR Returns entered in webform don't reflect in echoed string

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
3dron
Forum Commoner
Posts: 40
Joined: Sat Feb 01, 2003 10:25 pm

CR Returns entered in webform don't reflect in echoed string

Post by 3dron »

I am using something similiar to

echo ereg_replace(" ","<p>",$row_test('review'));

to add a <p> at "3 spaces" in a string stored in a database.

This string is entered by a web form that I wan't users just to hit return to have it show when the string is echoed back out.

Why do "returns" not show when echoed out? In the database the "return" exists.

Is there any other character I can replace (one that represents the return) with ereg_replace? or another easier way?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

The easiest way is to use nl2br() on the output. This will add HTML break tags (<br />) next to line break characters (\n).

Mac
Post Reply