1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

My article can not be stored in a database and disappeared. Help me, friends

Discussion in 'PHP' started by fixesign, Feb 1, 2011.

  1. #1
    When I create an article, and in the article there are punctuation marks (') / single quotes, my articles are not stored and disappeared.
    For example, in the words: I'm, Online's Story, Don't. Please Help Me Friends.
     
    fixesign, Feb 1, 2011 IP
  2. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #2
    when executing a query with that kind of string use

    'update table set columnOne = "'.mysql_real_escape_string($string) . '"'';
     
    bartolay13, Feb 1, 2011 IP
    fixesign likes this.
  3. fixesign

    fixesign Member

    Messages:
    175
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    28
    #3
    I do not understand, how to install the string above? Can you describe for me, friend?
    I have sintax as follows:

    function antislashes($data){
    $filter = stripslashes($data);
    return $filter;
    }

    $content = antislashes ($_POST[content_textarea]);

    mysql_query("INSERT INTO article (title, content) VALUES ('$_POST[title]', '$content')");

    mysql_query("UPDATE article SET content = '$content' WHERE id_article='$_POST[id]' ");
     
    fixesign, Feb 2, 2011 IP
  4. TimK

    TimK Peon

    Messages:
    51
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    function antislashes($data){
    $filter = stripslashes($data);
    return $filter;
    }
    
    $preContent = antislashes ($_POST[content_textarea]);
    $content = mysql_real_escape_string($preContent);
    
    mysql_query("INSERT INTO article (title, content) VALUES ('$_POST[title]', '$content')");
    
    mysql_query("UPDATE article SET content = '$content' WHERE id_article='$_POST[id]' ");
    
    PHP:
    Try that.
     
    TimK, Feb 2, 2011 IP
    fixesign likes this.
  5. spaceman12

    spaceman12 Active Member

    Messages:
    60
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    63
    #5
    mysql_real_escape_string($variable) should perfectly work fine. Always use mysql_error() function when doing some sql related work so that you dont waste much of your time trying to figure out where in your code it goes wrong when some unexpected error occurs withing your code.
     
    spaceman12, Feb 3, 2011 IP
    fixesign likes this.
  6. fixesign

    fixesign Member

    Messages:
    175
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    28
    #6
    Thank very much TimK, bartolay13, spaceman12.
    I actually got something very valuable here. Very perfect.
     
    fixesign, Feb 3, 2011 IP