CKEditor showing HTML tags instead of rendering it

Discussion in 'Programming' started by shivampaw, Mar 15, 2014.

  1. #1
    Hi,

    I made a CMS following a youtube series and now when I am adding the WSYWIG thing (CKEditor) it is displaying the text as html tags.
    [​IMG]

    Here is my code that I am using for displaying the text from the DB.

    
    // Query the body section for the proper page
    $query = mysql_query("SELECT pagebody FROM pages WHERE id='$pageid' LIMIT 1") or die (mysql_error());
    while ($row = mysql_fetch_array($query)) {
      $body = $row["pagebody"];
    }
    mysql_free_result($query);
    
    Code (markup):
    This is what the code looks like in the database:
    
    &lt;h1&gt;Welcome to Clashing Clans&lt;/h1&gt;<br />
    <br />
    &lt;hr /&gt;<br />
    &lt;p&gt;This is a site made for YOU to easily advertise your clans by making pages for them that everyone can view.&lt;/p&gt;<br />
    <br />
    &lt;p&gt;There are many other things on this site as well.&lt;/p&gt;<br />
    <br />
    &lt;hr /&gt;<br />
    &lt;p&gt;Thank You,&lt;/p&gt;<br />
    <br />
    &lt;div style=&quot;background:#eee;border:1px solid #ccc;padding:5px 10px;&quot;&gt;Shivam Paw&lt;/div&gt;<br />
    <br />
    &lt;div style=&quot;background:#eee;border:1px solid #ccc;padding:5px 10px;&quot;&gt;Site Admin&lt;/div&gt;<br />
    <br />
    &lt;p&gt;&amp;nbsp;&lt;/p&gt;<br />
    <br />
    &lt;p&gt;&amp;nbsp;&lt;/p&gt;<br />
    <br />
    &lt;p&gt;&amp;nbsp;&lt;/p&gt;<br />
    
    Code (markup):
    Thank You,

    Shiv
     
    Solved! View solution.
    shivampaw, Mar 15, 2014 IP
  2. #2
    Change this:

    
    $body = $row["pagebody"];
    
    PHP:
    To:


    
    $body = html_entity_decode($row["pagebody"]);
    
    PHP:
     
    ThePHPMaster, Mar 15, 2014 IP
  3. shivampaw

    shivampaw Greenhorn

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    Thanks it worked!

    Now though, one break line in the editor is a massive space when displayed. Any ideas?
    Also when creating/editing a page the images overflow the editor and require scrolling so is there anyway I can make that so it fits the editor?

    Thanks!
     
    shivampaw, Mar 17, 2014 IP
  4. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #4
    Are you adding the <br /> at some point? I am just wondering since <br /> is the only thing not encoded. You do not need the <br /> as you already have the <p> tags to create the newline. <p> with <br /> makes double lines.

    Haven't worked with ckeditor for a while, but you can have a JS code that resizes them to fit the screen. Alternatively if they are in a container, you can make them sized relative to the container.
     
    ThePHPMaster, Mar 17, 2014 IP
  5. shivampaw

    shivampaw Greenhorn

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #5
    I'm not sure - how can I check/fix it?
     
    shivampaw, Mar 18, 2014 IP