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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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