Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67441

Line breaks into database

$
0
0

I am making a posts area for readers, my problem is that when a user inserts a new post it is saved into the database in this form:

Some say the world will end in fire,<br /> Some say in ice.<br /> From what I’ve tasted of desire<br /> I hold with those who favor fire.<br /> But if it had to perish twice,<br /> I think I know enough of hate<br /> To say that for destruction ice<br /> Is also great<br /> And would suffice.

I want it to be saved like this:

 Some say the world will end in fire,<br />
 Some say in ice.<br />
 From what I’ve tasted of desire<br />
 I hold with those who favor fire.<br />
 But if it had to perish twice,<br />
 I think I know enough of hate<br />
 To say that for destruction ice<br />
 Is also great<br />
 And would suffice.

I want it to make "enter" after each line break with keeping the tag (for editing issues)

Here are my current posting text parameters before inserting to database

$body = strip_tags($body);
$body = mysqli_real_escape_string($this->con, $body); 
$body = str_replace('\r\n', "\n", $body);
$body = nl2br($body);

any help, please


Viewing all articles
Browse latest Browse all 67441

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>