br3nn4n Posted August 9, 2009 Share Posted August 9, 2009 Hey, I've got a database that stores HTML mixed with PHP in one of the table cells. It's basically all the content for a particular page; I have a row for each page with all the HTML and PHP code. Anyway, with Daniel0's help I got it working so that both parse correctly (thanks again!!) but the problem comes when I want to simply output the pure code (and NOT parse any of it) to a simple textarea. Here's what happens -- It gets to a certain point in placing the code in the textarea, and then...seems to parse some of the HTML or something? See: It creates a new textarea, but I just want it to output all the code to the one it's in! It's because it's closing the one it's putting the code in, I'm assuming, but how do I fix that? Here's everything after it stops outputting: </textarea></td></tr> <tr><td><textarea name="content" rows="50" cols="50"><?=$qa['content']; ?></textarea></td></tr> <tr><td class="button"><ul><li><a href="#" onclick="document.forms['pageeditor'].submit;"><span>Save changes</span></a></li></ul> </td></tr> </form> <tr><td></td><td></td><td><a href=".....?page=pages&edit=<?=$qa['id'];?>" title="Edit this page's content"></a></td><td></td><td></td></tr> </table> </p></textarea></td></tr> <tr><td class="button"><ul><li><a href="#" onclick="document.forms['pageeditor'].submit;"><span>Save changes</span></a></li></ul> </td></tr> </form> </table> </p> This may be more of an HTML question but I'm thinking that in PHP I can somehow stop it from closing the textarea...although...not sure. It seems like I just need to stop it from closing that textarea (which is where it starts outputting what's in the code instead of just showing the source. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/169520-stop-textarea-from-being-closed/ Share on other sites More sharing options...
wildteen88 Posted August 10, 2009 Share Posted August 10, 2009 Its because of the textarea you have in the code you're editing it is ending your textarea prematurely. Quote Link to comment https://forums.phpfreaks.com/topic/169520-stop-textarea-from-being-closed/#findComment-894418 Share on other sites More sharing options...
bundyxc Posted August 10, 2009 Share Posted August 10, 2009 Hard to tell without you posting some input. We know that the output wasn't what we were looking for, but that's about it: Garbage in, garbage out. Quote Link to comment https://forums.phpfreaks.com/topic/169520-stop-textarea-from-being-closed/#findComment-894419 Share on other sites More sharing options...
br3nn4n Posted August 10, 2009 Author Share Posted August 10, 2009 You're absolutely right and I've realized that since posting this and rereading my code a couple times. It's actually producing everything after that closing of the textarea...which indeed makes perfect sense if it's escaping out of my textarea...bad code So if I need that </textarea> in there (it's part of the code for that particular page) how can I, say, escape it so that it doesn't affect the textarea it's in? I'm thinking I can maybe have all <textarea></textarea> tags replaced with <ta></ta> (and then when I want to code a textarea, just stick in the <ta></ta> tags). That would fix the problem right? I know enough regex to do that Thanks! EDIT: @buddyxc - all the input (enough of it to show where the error starts) is in the screenshot See the opening <textarea> tag and then some PHP? after what shows in the screenshot, the rest of the code is below in my original post Of course, I can post all of it together if ya want Quote Link to comment https://forums.phpfreaks.com/topic/169520-stop-textarea-from-being-closed/#findComment-894421 Share on other sites More sharing options...
wildteen88 Posted August 10, 2009 Share Posted August 10, 2009 Use htmlentities when editing the code in the textarea. <tr><td><textarea name="content" rows="50" cols="50"><?=htmlentities($qa['content'], ENT_QUOTES); ?></textarea></td></tr> When done editing use html_entity_decode, eg $edited_code = html_entity_decode($_POST['content'], ENT_QUOTES); Quote Link to comment https://forums.phpfreaks.com/topic/169520-stop-textarea-from-being-closed/#findComment-894690 Share on other sites More sharing options...
br3nn4n Posted August 17, 2009 Author Share Posted August 17, 2009 Ahhh great suggestion! I'd still love to be able to just edit it like I were a...text file...for example. With html entities I'll have a textarea full of <s and >s. While the textarea stays closed it makes it super hard to edit. I'm looking at throwing this in there - http://javascript.internet.com/snippets/convert-html-entities.html - decodes HTML entities. I'm not sure if it'll close the textarea though, but it seems like if it's just changing the text inside it than it wouldn't right? Thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/169520-stop-textarea-from-being-closed/#findComment-899953 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.