Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder stevenmw's Avatar
    Join Date
    Jun 2007
    Location
    OK
    Posts
    497
    Thanks
    27
    Thanked 31 Times in 31 Posts

    Posting Apostrophes

    I've written a simple script that submits text from a textarea into a database using the $_POST function.

    For some reason the text area cannot submit apostrophes.

    Can anyone tell me how to make my form submit apostrophes?

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,472
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    Show us your script ...

    It relates to "stripslashes"

  • #3
    Regular Coder stevenmw's Avatar
    Join Date
    Jun 2007
    Location
    OK
    Posts
    497
    Thanks
    27
    Thanked 31 Times in 31 Posts
    my code:
    PHP Code:
    require('config.php');

    $message $_POST['message'];
    $cat $_POST['cat'];
    $date date("dMy");
    $time date("h:ia");

    $query "INSERT INTO talk (id, message, date, time) VALUES ('', '$message', '$date', '$time')";

    mysql_query($query) or die(mysql_error()); 

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,472
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    Steven, Try this ...

    PHP Code:
    require('config.php'); 

    $message mysql_real_escape_string($_POST['message']); 
    $cat $_POST['cat']; 
    $date date("dMy"); 
    $time date("h:ia"); 

    $query "INSERT INTO talk (id, message, date, time) VALUES ('', '$message', '$date', '$time')"

    mysql_query($query) or die(mysql_error()); 

    Then, the apostrophe contains a slash ...
    So when you read it back out, you'll need to remove slashes ...

    $message = stripslashes($message);

  • Users who have thanked mlseim for this post:

    stevenmw (10-21-2009)


  •  

    Posting Permissions

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