php get data from mysql

Discussion in 'PHP' started by Ovlznvvz, Jul 22, 2011.

  1. #1
    Hello.
    I use a text box to insert data to mysql.
    The box is secured with the following:
    mysql_real_escape_string(stripslashes(trim(htmlent ities(strip_tags( $_POST['text_box'] )))));
    When i type in tʰe it stores it into the database but when showing,it appears:
    "& # 6 8 8 ;" ( with no space beetween letters because here it shows correctly if i have no space)


    where is the solution?
     
    Ovlznvvz, Jul 22, 2011 IP
  2. dthoai

    dthoai Member

    Messages:
    106
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    38
    #2
    When you insert data to mysql, you use:

    
    mysql_real_escape_string($_POST['text_box'])
    
    Code (markup):
    When you retrieve data from mysql, you use:

    
    stripslashes($value)
    
    Code (markup):
     
    dthoai, Jul 22, 2011 IP
  3. exodus

    exodus Well-Known Member

    Messages:
    1,900
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    165
    #3
    "htmlent ities" is the php code that to transforming the string into html syntax. You could use html_entity_decode to undo that for the text box field. Don't store the info like that decoded though cause it defeats the purpose of changing the chars into html syntax.
     
    exodus, Jul 22, 2011 IP