Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
Rob
Forum Commoner
Posts: 33 Joined: Fri Oct 03, 2003 3:18 pm
Post
by Rob » Tue Oct 28, 2003 3:05 pm
Whenever a user enters a story and sends to the server, anywhere they hit enter (to make a new line...) it turns into a space instead..what do I do?
qads
DevNet Resident
Posts: 1199 Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane
Post
by qads » Tue Oct 28, 2003 3:12 pm
Code: Select all
<?php
$blockoftext = nl2br($_POST['blockoftext']);
?>
make sure you use it before inserting the record into the database.
Rob
Forum Commoner
Posts: 33 Joined: Fri Oct 03, 2003 3:18 pm
Post
by Rob » Tue Oct 28, 2003 6:35 pm
Thanks that worked
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Wed Oct 29, 2003 5:05 am
Don't use nl2br() before putting data into the database, because then when you come to edit the record you'll get a bunch of unwanted <br />'s, instead only use nl2br() when you display the story and keep it unchanged in the database.
Mac
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Wed Oct 29, 2003 5:06 am
P.S. The enters are being changed into new line characters (\n on *nix, \r\n on Windows and \r, IIRC, on Macs).
Mac