Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7688331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:53:44+00:00 2026-05-31T19:53:44+00:00

I am having trouble with a site administration tool I built, It allows me

  • 0

I am having trouble with a site administration tool I built, It allows me to edit articles for my website. I am using google-code-prettify as my articles are on C++ programming, I then use the <pre class="prettyprint"> </pre> tags to specify I am about to start writing C++ code. The problem is that when I write say,

#include <iostream>

And then insert this into my mySQL database, it will properly add insert the text with the <>
but when I request the info and display it in a article viewing page. It will break the page as HTML thinks I am trying to add an HTML tag. So when using the &lt; &gt; tags it will properly add these to my database and the article viewer page will properly read the

#include <iostream>

But if I go want to edit the article, it will read the &lt;&gt; as <>. Which on another insert will bring me back to the original problem of inserting the <> into the database and having them not in my viewer. How can I stop HTML from changing &lt;&gt; into the <>, but only if it is inside <pre class"prettyprint"></pre> within my textarea. I have got it working where it will convert everything in the text area using jquery.

$("#contbox").each(
  function () {
    $(this).text($(this).html()).html();
 }
);

Where #contbox is the id of my textarea, however I cannot figure out how to limit this to only within the pre tags,

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T19:53:45+00:00Added an answer on May 31, 2026 at 7:53 pm

    Best practice is to store the file as unencoded strings and only encode when it is time to display. The biggest reason for this is the same data may be displayed/used in multiple places that require different encoding (or none at all). If your website allows a user to enter HTML formatted text, you should store it in the database exactly as entered and when it comes time to display it to the end user call the appropriate encoding.

    You need to call the appropriate encoding on the server side. This would prevent malicious code from being executed before your javascript can run and encode the data and it also means that your user would still see valid text if they have javascript disabled.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having trouble linking the Stomp.framework into an iPhone SDK application. http://code.google.com/p/stompframework/ I follow the
I am developing a site using kohana 2.3 and am having trouble with a
I'm using YSlow to improve the speed of my site, and I'm having trouble
I've been rebuilding my site with code igniter and am having trouble validating the
I am navigating a site using python's mechanize module and having trouble clicking on
I am having trouble getting the built-in jquery tabs working on my site. I'm
I'm having trouble showing a list of images on a site. using this question
I've recently started having trouble logging into my site using Facebook. I keep seeing
I am having trouble doing something simple like the following using (SPSite site =
Please consider this site . I'm having trouble stretching the submenu list items in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.