bedted Posted March 5, 2007 Share Posted March 5, 2007 Hi, I'm sure this is a simple question but one I've been tearing my hair out at. Basically I've got the contents of my frontpage held in a mysql database and its formatted with HTML Tags. When I view the frontpage eveything is fine. I know want to create a page that will lets admin users update the frontpage by editing the HTML code stored in the database. The problem lies when trying to extract the data back out and display it in a form where they can edit it. As the code is formatted in HTML it contains lots of " " " e.g. ========================================================== <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center"> <tr> <td width="100%"><p align="justify"><strong><u> ========================================================== etc etc etc So when I put it into the 'value' part of my edit page it doesn't work properly due to the ( " " " "). I'm extracting the information like the below: <?php $sql = "SELECT body FROM frontpage WHERE frontpage_id = 1"; $result = @mysql_query($sql); $row = @mysql_fetch_array($result, MYSQL_NUM); $body = $row[0]; and then using this to input it into the form: <textarea rows="30" cols="108" name="frontpage" value="<?php echo $body; ?>"></textarea> I'm sure it must be possible to get the code into the form as it should be but I'm stumped so I hope someone can help! Thanks in Advance "A very stuck" Ed Glover Link to comment https://forums.phpfreaks.com/topic/41351-displaying-html-code-help-in-a-mysql-database/ Share on other sites More sharing options...
gargoylemusic Posted March 6, 2007 Share Posted March 6, 2007 try looking at addslashes() and stripslashes() (http://us3.php.net/addslashes). That might help escape the quotation marks so they're more palatable with your SQL queries (not to mention prevent sql-injection...) Link to comment https://forums.phpfreaks.com/topic/41351-displaying-html-code-help-in-a-mysql-database/#findComment-200555 Share on other sites More sharing options...
JasonLewis Posted March 6, 2007 Share Posted March 6, 2007 also try using the htmlentities() when displaying the data. Link to comment https://forums.phpfreaks.com/topic/41351-displaying-html-code-help-in-a-mysql-database/#findComment-200566 Share on other sites More sharing options...
bedted Posted March 6, 2007 Author Share Posted March 6, 2007 Thanks guys, I'll give them a try tonight, fingers crossed for success! Cheers Ed Link to comment https://forums.phpfreaks.com/topic/41351-displaying-html-code-help-in-a-mysql-database/#findComment-200614 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.