Jump to content

Unwanted newline when saving to database


keeps21

Recommended Posts

I'm using the Zend Framewrok 1.8.0, mysql 5.051b and tinymce as the editor.

 

When the data from a textarea is saved into the database each <p> tag is on a newline in the database field.

 

This is how it looks in the database

[pre]

<p>Paragraph1 this is filler text.</p>

<p>Paragraph2 This is filler text.</p>

[/pre]

 

This is causing problems when creating a javascript variable from the data in the field as it adds the second paragraph onto the next line in the source code which breaks the script.

 

This is how it looks when assigned to a js variable with tags stripped

 

$nvar = "Paragraph1 this is filler text.
            Paragraph2 This is filler text."

 

I'm completely stumped as to how to fix it.

 

 

I can't strip the tags out because I need the formatting created in tinymce to be saved into the database to be output.

 

There aren't any \n or \r tags in the database.

 

It's just a case of every new <p> tag in the database text being saved onto a new line.

 

ie like this

[pre]

<p>Paragraph one, this is text</p>

<p>Paragraph two, this paragraph has more text than paragraph one.</p>

[/pre]

 

rather than like this

[pre]

<p>Paragraph one, this is text</p><p>Paragraph two, this paragraph has more text than paragraph one.</p>

[/pre]

 

if I could save it to the database the latter way then there'd be no problems.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.