#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    San Antonio, Texas, USA
    Posts
    23
    Rep Power
    0
    Well I created a script that dumps info into a table, i have a biography field and was wounder if MySQL would out put html tags such as <P> or does it just ato format from the way you type it in? Any help would be appreciated.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    300
    Rep Power
    15
    I don't quite understand what are you asking, but ify ou are asking whether or not you can store HTML tags in MySQL table, yes you can. You simply store them as normal text. In the output, they will be formatted on the page. So if you insert something like:
    <a href="http://www.devshed.com">A link</a> in the MySQL table, it would become a link in your HTML/PHP document...

    HTH
  4. #3
  5. No Profile Picture
    Robert_J_Sherman
    Guest
    Devshed Newbie (0 - 499 posts)
    Something to bare in mind though, it's
    a good idea to "escape" special HTML characters, or any scripting you place
    in your mysql tables.

    In short, if you try to put something like an ' (apostrophe) in your mysql table, you can certainly expect to get a mysql error, as the character needs to be escaped (')...



    ------------------
    SnR Graphics,
    Low Cost Hosting and Web Development.
  6. #4
  7. No Profile Picture
    Francine
    Guest
    Devshed Newbie (0 - 499 posts)
    How do I get it so that mysql will NOT return html. I wouldn't want users posting <table> I don't want to check if it will work or not. "</TABLE>" and messing up my page.
  8. #5
  9. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    Francine,

    I wouldn't worry about how it's stored in MySQL, but the problem is displaying it back in the page.

    You should use htmlentities() on the retrieved data before displaying. That way if someone enters <table> then it will be displayed as <table> and not interpretted as an HTML tag by the browser.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    300
    Rep Power
    15
    How about strip_tags?? Wouldthat one work??
  12. #7
  13. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    Yes, it would, however you'd loose the data. If you are developing a site where HTML would NEVER appear in the text that would be fine. A forum like this one and that would be a BAD idea.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    300
    Rep Power
    15
    rok k, what do you mean?? I played a little with the strip_tags function, but I don't know exactly how it works. Could you iluminate me please??
  16. #9
  17. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    Look at the previous posts where we typed in <table>

    If you use strip_tags() all tags would be removed. So the string <table> wouldn't appear in the output. Using htmlentities() the < signs would be converted to &amp;gt; etc. so the typed text will actually appear but not be executed as html code.
  18. #10
  19. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    7
    Rep Power
    0
    Use htmlentities() if you want the tags to show up as part of the text (for example on a message board where people are discussing html).
    This is <b>bold</b> is displayed as This is <b>bold</b>

    Use strip_tags() if you want to remove the user's tags and ignore all their html code.
    This is <b>bold</b> is displayed as This is bold

    If you want to let certain tags work, do it like this:
    $outstring = striptags($instring,"<b>,<i>");
    This is <b>bold</b> is displayed as This is bold

    [This message has been edited by danmckay (edited July 30, 2000).]
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    300
    Rep Power
    15
    Thanks a lot people, that was really helpful...

Similar Threads

  1. How to get client email??Help plz
    By Gecko22 in forum ASP Programming
    Replies: 12
    Last Post: January 22nd, 2004, 02:40 PM
  2. Build HTML tables with multiple mySQL queries
    By SailFan in forum PHP Development
    Replies: 5
    Last Post: January 19th, 2004, 12:25 PM
  3. not returning records when it should
    By aliaga61 in forum ASP Programming
    Replies: 3
    Last Post: January 16th, 2004, 11:57 AM
  4. Help!!! Updating MySQL Record using HTML Form
    By kashaf in forum PHP Development
    Replies: 2
    Last Post: January 16th, 2004, 10:32 AM
  5. 'Object required' error
    By aliaga61 in forum ASP Programming
    Replies: 1
    Last Post: January 16th, 2004, 09:48 AM

IMN logo majestic logo threadwatch logo seochat tools logo