phpbeginner Posted January 11, 2007 Share Posted January 11, 2007 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. Quote Link to comment Share on other sites More sharing options...
trq Posted January 11, 2007 Share Posted January 11, 2007 [quote]when he goes back into this section to do an edit the fields are blank[/quote]Back from where? Please be clearer in your explination or post the relevent code. Quote Link to comment Share on other sites More sharing options...
phpbeginner Posted January 11, 2007 Author Share Posted January 11, 2007 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. Quote Link to comment Share on other sites More sharing options...
Draicone Posted January 11, 2007 Share Posted January 11, 2007 Try right clicking and click view source (view page source in firefox), and look for the content inside the textarea html tag. It may just be a problem of the tag being prematurely closed, or the value not inserted between the tags properly. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 11, 2007 Share Posted January 11, 2007 Enter in a text box = \r\nI bet these characters are causing the problem. Quote Link to comment Share on other sites More sharing options...
phpbeginner Posted January 11, 2007 Author Share Posted January 11, 2007 Exactly, I enter those and same problem as hitting enter key. So what now ? Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 11, 2007 Share Posted January 11, 2007 What are you running on your input to sanitize it? mysql_real_escape_string? add_slashes? Quote Link to comment Share on other sites More sharing options...
phpbeginner Posted January 11, 2007 Author Share Posted January 11, 2007 huh ? Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 11, 2007 Share Posted January 11, 2007 before putting the info in the database, what do you do to escape it? Quote Link to comment Share on other sites More sharing options...
phpbeginner Posted January 11, 2007 Author Share Posted January 11, 2007 Nothing, I am just entering text. Do I need to add something within the text area ><?php echo STRIPSLASHES(TRIM($content))?>< Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 11, 2007 Share Posted January 11, 2007 Did you do what draicone suggested? Quote Link to comment Share on other sites More sharing options...
phpbeginner Posted January 11, 2007 Author Share Posted January 11, 2007 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> Quote Link to comment Share on other sites More sharing options...
trq Posted January 11, 2007 Share Posted January 11, 2007 Remove the input='' tags. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 11, 2007 Share Posted January 11, 2007 Textarea doesn't have value. You put the value between the two tags.<textarea><?=$content?></textarea> Quote Link to comment Share on other sites More sharing options...
trq Posted January 11, 2007 Share Posted January 11, 2007 Hehe.. yeah, and the value='' tag. Quote Link to comment Share on other sites More sharing options...
phpbeginner Posted January 11, 2007 Author Share Posted January 11, 2007 Thank you so much jesirose !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Works beautiful ! I would have played with that for who knows how much longer. Thanks Again ! Quote Link to comment Share on other sites More sharing options...
phpbeginner Posted January 12, 2007 Author Share Posted January 12, 2007 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. Quote Link to comment Share on other sites More sharing options...
Draicone Posted January 13, 2007 Share Posted January 13, 2007 [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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.