Jump to content

Text Area Problems


phpbeginner

Recommended Posts

This is driving me nuts and probably overlooking something very simple. Its a php code with mysql and I have a problem with a particular part of this in an Admin Panel.

The Admin can add/edit/delete text which works fine, but in the textarea box if the Admin hits the enter key to start a new line when he goes back into this section to do an edit the fields are blank. This only happens when he hits the enter key in a textarea block. If you just keep typing away everything is fine and there are no problems when you go in to do an edit.
Link to comment
https://forums.phpfreaks.com/topic/33821-text-area-problems/
Share on other sites

When he goes back in to his Admin Panel to do an edit, in the section where he hit the enter key within the textarea, nothing is there. The info is still in the MYSQL database and he can delete this or leave it be, but he cannot edit this as nothing displays.

Ex: I login to my Admin Panel, add a story with a title/date/text to display on my site. Everything updates fine and displays on the website and I can log back in and edit as I wish.

I log back in to add another story add a title/date/text. This time when I enter text in the textarea I hit the enter button to start a new line or paragraph. Again, everything is updated on my website and displays fine but when I log in to do an edit on this story none of the fields will display. This only happens when I hit the enter key within the textarea.

Link to comment
https://forums.phpfreaks.com/topic/33821-text-area-problems/#findComment-158655
Share on other sites

Okay, I went into the edit section where I had entered \r\n in the first box.......Here is my source code....it shows second box with an input value of '\r\n'' but its not displaying.

<tr>
                                <td>
                                    <p>Section Title:</p>
                                </td>
                                <td>
                                    <input type='text' value='afadf' name='txtTitle' size='50' maxLength='50'>
                                </td>
                            </tr>
                            <tr>
                                <td valign='top'>
                                    <p>Paragraph 1:</p>
                                </td>
                                <td>
                                    <textarea value='\r\n' input='' name='taIntro' rows='7' cols='50'></textarea>
                                </td>
                            </tr>
                            <tr>
                                <td valign='top'>
                                    <p>Paragraph 2:</p>
                                </td>
                                <td>
                                    <textarea value='' input='' name='taIntro2' rows='7' cols='50'></textarea>
                                </td>
                            </tr>
Link to comment
https://forums.phpfreaks.com/topic/33821-text-area-problems/#findComment-158725
Share on other sites

Okay back for dumb question # 2. When adding text to the Admin Panel textarea and hitting return for a new paragraph, it doesn't break into a new paragraph on the site. I check MYSQL and its a new paragraph in there but how do I get this to display as a new paragraph on the webpage.
Link to comment
https://forums.phpfreaks.com/topic/33821-text-area-problems/#findComment-158795
Share on other sites

[code]value='\r\n'[/code]
As mentioned before, this tag is invalid. Also, a \r\n in HTML is meaningless, it translates to a carriage return followed by a line feed (i.e. an overloaded windows new line). Replace \r\n with <?php echo "\r\n"; ?> to see how it works. If your SQL surrounds the value inserted with single quotes, try adding this line just before it, assuming $html is the content of the textarea tag within the $_POST array:
[code]$html = str_replace("'","\\'",$html);[/code]
This should effectively escape it. If you use double quotes:
[code]$html = str_replace('"','\\"',$html);[/code]
If you use that other quote symbol, the `, just make sure there aren't any in your textarea tag and ignore this.
Link to comment
https://forums.phpfreaks.com/topic/33821-text-area-problems/#findComment-159887
Share on other sites

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.