HTML Output With PHP

Discussion in 'PHP' started by bloard, Apr 28, 2007.

  1. #1
    Getting ready to throw together my own basic CMS, and I can hack around with php a little and usually get things to work, but I am certainly considered a beginner. What I want to do sounds pretty easy.... I want to store the guts of content pages in mysql marked up in HTML, and then output them using php calling the database.

    Now, it looks to me like I should hook up something like fck editor on whatever page I am creating the content, then store it in my database. But I am sure there are plenty of little things I am about to learn the hard way.

    Could anyone save me a little headache and tell me if there is anything special I need to know when doing this. Is there any particular html tag that causes a problem when php tries to output it that I should be aware of?

    Lets just say I want to output the saved html code on a page... what is the preferred way to do this? Lets say that I assign variable $content= the correct database field. Then can I just echo '$content'; or is there something more that I need to do to get it to work right?

    Thanks in advance for your help.
     
    bloard, Apr 28, 2007 IP
  2. SoKickIt

    SoKickIt Active Member

    Messages:
    305
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    70
    #2
    Nope.

    echo $content; would work fine.
     
    SoKickIt, Apr 28, 2007 IP
  3. bloard

    bloard Peon

    Messages:
    180
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Great... now, do I need to do addslashes before sending the html to my database and striplashes before output to the user's browser? Or, is this unnecessary... or is there another way?
     
    bloard, Apr 28, 2007 IP
  4. SoKickIt

    SoKickIt Active Member

    Messages:
    305
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    70
    #4
    You should use the mysql_real_escape_string() function.

    Example:

    $sql = "INSERT INTO table SET content = '" . mysql_real_escape_string($content) . "'";
     
    SoKickIt, Apr 28, 2007 IP