Results 1 to 8 of 8

Thread: html tags in output

  1. #1
    Join Date
    Feb 2009
    Posts
    156
    Thanks
    0
    Thanked 4 Times in 3 Posts

    Default html tags in output

    i am using a nl2br tag...


    nl2br($text)


    but in text there are somr <img> tags... in output nl2br method convert <img> to special chars...
    instead of showing me pictur for img tag it just displays a <img> tag with full source.....

    what to do..?

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    nl2br() doesn't do that... are you sure you don't have something like htmlentities() running at another point in your script?

  3. #3
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    If you view the souce does it say &lt;img ... &gt;?

    We'd need to see your code for a more detailed answer.

    Actually if you have "new lines"(\n or\r) in your source code i guess this code occur as well because it would write it as

    <img <br /> src="" />

    but that would display on more than 1 line. So seeing the actual source of the output could help as well as the code.
    Corrections to my coding/thoughts welcome.

  4. #4
    Join Date
    Feb 2009
    Posts
    156
    Thanks
    0
    Thanked 4 Times in 3 Posts

    Default

    no i never used the function line htmlentities

    yes my out put code is lying here...
    Code:
     &lt;img src='img/smilies/icon_e_biggrin.gif'&gt; <br />
     &lt;img src='img/smilies/icon_eek.gif'&gt; <br />
     &lt;img src='img/smilies/icon_razz.gif'&gt; <br />
     &lt;img src='img/smilies/icon_e_surprised.gif'&gt;ops:  <br />
     &lt;img src='img/smilies/icon_e_confused.gif'&gt;: <br />
     &lt;img src='img/smilies/icon_cry.gif'&gt; <br />


    i only used the nl2br function

  5. #5
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    I have no idea. I've tested
    PHP Code:
    <?php

    $tag 
    '<img src="test.jpg">'."\n";
    echo 
    nl2br($tag);

    ?>
    locally and on two different live servers, each time I got
    HTML Code:
    <img src="test.jpg"><br />

  6. #6
    Join Date
    Feb 2009
    Posts
    156
    Thanks
    0
    Thanked 4 Times in 3 Posts

    Default

    ok.. leave it what nl2br does....



    is ther any method to convert such symbols to proper <img > tag?

  7. #7
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    htmlspecialchars_decode();

    I'd try and find what it is being converted though.
    Corrections to my coding/thoughts welcome.

  8. #8
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    absolutely, otherwise, you might not catch it at the right spot; or it could happen again somewhere

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •