Textarea Formating - PHP Mysql

Discussion in 'PHP' started by nile1483, Jun 25, 2008.

  1. #1
    Dear friends,

    I need to insert textarea data into mysql and retrieve it in web page.

    so please tell me how to format it.

    Thanks
     
    nile1483, Jun 25, 2008 IP
  2. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #2
    Always use

    addslashes($var)
    PHP:
    when adding variables to your database. You can use stripslashes($row['var']) when you're displaying them again although it might work without this.
     
    Weirfire, Jun 25, 2008 IP
  3. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #3
    Forget just addslashes...

    Use mysql_real_escape_string (or mysqli version.)
     
    Danltn, Jun 25, 2008 IP
  4. nile1483

    nile1483 Active Member

    Messages:
    345
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    60
    #4
    Thanks for your suggestion i will check it

    Thanks
    nile
     
    nile1483, Jun 25, 2008 IP
  5. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #5
    What does mysql_real_escape_string do?
     
    Weirfire, Jun 26, 2008 IP
  6. wowla_123

    wowla_123 Peon

    Messages:
    147
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Escapes special characters in a string for use in a SQL statement.

    Source: PHP Manual
     
    wowla_123, Jun 26, 2008 IP
  7. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #7
    You also can use mysql_escape_string :) it's almost the same as mysql_real_escape_string
     
    EricBruggema, Jun 26, 2008 IP
  8. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #8
    It looks like it's particularly useful for stopping misuse of login queries.
     
    Weirfire, Jun 26, 2008 IP
  9. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #9
    No, mysql_real_escape_string is better if you can use it. They are nearly functionally identical however mysql_escape_string() does not take a connection argument and does not respect the current charset setting - and you want it to respect the current charset setting.

    It is advised you use mysql_real_escape_string however because mysql_escape_string is deprecated.

    Dan
     
    Danltn, Jun 26, 2008 IP