Insert textarea in PHP ... not accepting '

Sharky Forums


Results 1 to 3 of 3

Thread: Insert textarea in PHP ... not accepting '

  1. #1
    Expensive Sushi
    Join Date
    Jan 2002
    Posts
    26

    Insert textarea in PHP ... not accepting '

    I've written a simple php-script that puts info in a sql-DB.

    One of the areas to fill in is a textarea... and it work fine for general text. Howerer as soon as there is a ' in the textarea the entry is not put in the DB ... the old entry remains ...

    Isn't there some php-funtion that allows me to put ' in the textarea and the SQL-DB just accepts it ? Or do I have to find another method ?
    I've already used a php-funtion to retain the breaks in the textarea by the ln2br function... I was wondering if there is some funtion like that that allows me to use ' in my textarea and enter it in the DB.

    Thx.
    Kim.

  2. #2
    Expensive Sushi
    Join Date
    Jan 2002
    Posts
    26
    Never mind... I found it

    When I added the info into the DB I did it like this :

    ... INSERT into TABLE info='$info' ...

    The ' in this line is interpreted with the ' from the textarea ... this was my problem. Fixed it with the \'

    Grtz.
    Kim.

  3. #3
    Hammerhead Shark
    Join Date
    Feb 2001
    Location
    Columbus, Ohio
    Posts
    1,277
    Don't manually code in the \. Everything entered into the database that is not completely controlled by you should have the addslashes() function ran on it like this:

    $var = addslashes($var);

    and when you are getting the var out of the db you should do:

    $var = stripslashes($var);


    stripslashes() will escape every character that needs to be in the database.

Posting Permissions

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