Welcome Guest, Not a member yet? Register   Sign In
Text escaping / unescaping help
#1

[eluser]Sceneshift[/eluser]
I hate myself for asking this question, but I can't seem to find a solution.

I have a text area, I am adding the contents to a database using active record. It's escaping all the apostrophes and adding \n's for line breaks, which is fine. I am happy with that.

How do I then take that data out of the database and display it in a nice manner? I tried using the typography helper, but it obviously doesn't work in conjunction with stripslashes which I need because of the escaped apostrophes.

Sorry for the stupid question!
#2

[eluser]stuffradio[/eluser]
In the main method call the method string helper:
Code:
$this->load->helper('string');

When pulling the data go:

Code:
$this->strip_slashes($text);
I think that should do it.
#3

[eluser]Sceneshift[/eluser]
Thanks a lot...

I am still getting \n's turning into just"n"'s now, any it seems I can even have one or the other.
#4

[eluser]xwero[/eluser]
the php way to display multiline texts is
Code:
nl2br(htmlentities($text));
But if you use the form helper the form_prep function is similar.
#5

[eluser]stuffradio[/eluser]
Oh yes,
xwero that is the best way to do it. I misread his thread. I too use that function to do this Smile
#6

[eluser]Sceneshift[/eluser]
Raaaaar this is driving me mad Smile

Entry looks like this in my database:

"line1\n\nline2" it's mysql_real_escape_string'd.

Then using <?=nl2br(htmlentities($text))?> I get:

"line1\n\nline2"

What am I doing wrong? Sorry guys.




Theme © iAndrew 2016 - Forum software by © MyBB