Render html with php

This is a discussion on "Render html with php" within the PHP Forum section. This forum, and the thread "Render html with php are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Dec 12th, 2006, 15:28
Junior Member
Join Date: Nov 2006
Location: London
Age: 22
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Render html with php

Such a frustrating day... web host has been on the blink but i have finally proved its not a problem with the apache set up on my laptop.

So, i must be doing something wrong with my coding. I am using a class called
textile to render the input in html. Unfortunately it is coming out as this.

<p>This is a test</p>

What do i have to need to do to make these tags actually be rendered by html?
Reply With Quote

  #2 (permalink)  
Old Dec 12th, 2006, 16:26
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: Render html with php

Are you saying that the page that is served up to the browser contains these tags but that they don't show?
Reply With Quote
  #3 (permalink)  
Old Dec 12th, 2006, 18:38
Junior Member
Join Date: Nov 2006
Location: London
Age: 22
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Render html with php

Yes. If i echo out <i>Text</i> then it comes back as Italic text. If i use textile, http://www.textism.com/tools/textile/ it just brings back the tags but doesn't process it into a formatted page. The same happens if input tags via my input form. It will store the text and tags ok but when it is called it doesn't work.

Furthermore when i use n12br it also just returns <br /> instead of an actual break. Is there something i need to put around the variable to make it show?
Reply With Quote
  #4 (permalink)  
Old Dec 12th, 2006, 21:03
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Render html with php

I use Textile all the time, I've never had problems with it. You're actually getting the HTML markup, not what it will look like in a browser. Could you upload this and link us up?
Reply With Quote
  #5 (permalink)  
Old Dec 12th, 2006, 21:04
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: Render html with php

Can you show us a complete example of the generated page?
Reply With Quote
  #6 (permalink)  
Old Dec 12th, 2006, 21:24
Junior Member
Join Date: Nov 2006
Location: London
Age: 22
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Render html with php

Here's an example of it not rendering... the sites not completed but you can see http://www.jasonstanley.co.uk/UNC/index.php?action=all

My script looks as follows. www.jasonstanley.co.uk/code.txt Sorry if the codings a little messy. Textile is used in the displayNews function
Reply With Quote
  #7 (permalink)  
Old Dec 13th, 2006, 00:31
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Render html with php

My guess is that you've got something in your PHP that is telling the string to turn HTML characters into entities. Textile itself will not turn a < be &lt, so there is something else in there that's doing it.
Reply With Quote
  #8 (permalink)  
Old Dec 13th, 2006, 11:03
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: Render html with php

As Ryan suggests, you need to look through your scripts to see where this code is being generated.
Code: Select all
<div class="newscontent">&lt;p&gt;This is a test&lt;/p&gt;<br /></div>
It's the fact that '<' is being replaced by '&lt;', etc., that is causing the problem.

I also notice that your html code contains tags like <CENTER>. These are deprecated in xhtml. You should be using css to centre items. As an additional note, tag (element) names should always be in lowercase with xhtml.
Reply With Quote
  #9 (permalink)  
Old Dec 14th, 2006, 07:30
Junior Member
Join Date: Nov 2006
Location: London
Age: 22
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Render html with php

Yeah geoff i know that, i was just using tables to structure the page to get it working. I am starting to design the page now and these things will all be removed.

It works if i remove the bbcode( ) around the $processed news variable. Can someone look over my code and see if they can see anything in this script that would have such an effect?

Code: Select all
<?php
function bbcode_format ($str) {
    $str = htmlentities($str);

    $simple_search = array(
                '/\[b\](.*?)\[\/b\]/is',                                
                '/\[i\](.*?)\[\/i\]/is',                                
                '/\[u\](.*?)\[\/u\]/is',                                
                '/\[url\=(.*?)\](.*?)\[\/url\]/is',                         
                '/\[url\](.*?)\[\/url\]/is',                             
                '/\[align\=(left|center|right)\](.*?)\[\/align\]/is',    
                '/\[img\](.*?)\[\/img\]/is',                            
                '/\[mail\=(.*?)\](.*?)\[\/mail\]/is',                    
                '/\[mail\](.*?)\[\/mail\]/is',                            
                '/\[font\=(.*?)\](.*?)\[\/font\]/is',                    
                '/\[size\=(.*?)\](.*?)\[\/size\]/is',                    
                '/\[color\=(.*?)\](.*?)\[\/color\]/is',        
                );

    $simple_replace = array(
                '<strong>$1</strong>',
                '<em>$1</em>',
                '<u>$1</u>',
                '<a href="$1">$2</a>',
                '<a href="$1">$1</a>',
                '<div style="text-align: $1;">$2</div>',
                '<img src="$1" />',
                '<a href="mailto:$1">$2</a>',
                '<a href="mailto:$1">$1</a>',
                '<span style="font-family: $1;">$2</span>',
                '<span style="font-size: $1;">$2</span>',
                '<span style="color: $1;">$2</span>',
                );

    // Do simple BBCode's
    $str = preg_replace ($simple_search, $simple_replace, $str);

    // Do <blockquote> BBCode
    $str = bbcode_quote ($str);

    return $str;
}



function bbcode_quote ($str) {
    $open = '<blockquote>';
    $close = '</blockquote>';

    // How often is the open tag?
    preg_match_all ('/\[quote\]/i', $str, $matches);
    $opentags = count($matches['0']);

    // How often is the close tag?
    preg_match_all ('/\[\/quote\]/i', $str, $matches);
    $closetags = count($matches['0']);

    // Check how many tags have been unclosed
    // And add the unclosing tag at the end of the message
    $unclosed = $opentags - $closetags;
    for ($i = 0; $i < $unclosed; $i++) {
        $str .= '</blockquote>';
    }

    // Do replacement
    $str = str_replace ('[' . 'quote]', $open, $str);
    $str = str_replace ('[/' . 'quote]', $close, $str);

    return $str;
}
?>
Reply With Quote
  #10 (permalink)  
Old Dec 14th, 2006, 20:46
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: Render html with php

It's the htmlentities function that is taking your '<' and converting that to &lt;, etc.
Reply With Quote
  #11 (permalink)  
Old Dec 15th, 2006, 01:09
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Render html with php

Yep... Knew that had to be in there somewhere.
Reply With Quote
  #12 (permalink)  
Old Dec 15th, 2006, 10:11
Junior Member
Join Date: Nov 2006
Location: London
Age: 22
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Render html with php

ah thank you so much
Reply With Quote
Reply

Tags
render html

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
attachMovie will not render in avi exactspace Flash & Multimedia Forum 0 Nov 13th, 2007 14:21
Help with my html totally new Web Page Design 12 May 30th, 2007 20:39
Render HTML inside CDATA with XSL zweb Other Programming Languages 0 Sep 10th, 2006 16:19
Html leonheart Introduce Yourself 3 Aug 19th, 2005 21:55


All times are GMT. The time now is 11:15.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43