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 3 of 3
  1. #1
    New Coder
    Join Date
    Apr 2011
    Posts
    24
    Thanks
    1
    Thanked 1 Time in 1 Post

    How to use ' sign in mysql queries.

    Hello,

    I'm sure it's very easy to solve, but I don't have a lot of time, so I even don't search for the solution by myself.

    So, mysql query breaks when the sign ' comes to the sentence. How is it possible to make these signs available with mysql query?

    My mysql_query variable is described like that:
    PHP Code:
    $mysql_query "INSERT INTO `table` (`id` ,`title` ) VALUES (NULL , '$sentence')"
    Thank you for your help!

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,986
    Thanks
    79
    Thanked 4,432 Times in 4,397 Posts
    mysql_real_escape_string( ).

    To wit:
    Code:
    $sentence = mysql_real_escape_string($sentence);
    $mysql_query = "INSERT INTO `table` (`id` ,`title` ) VALUES (NULL , '$sentence')";
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by withoutnick View Post
    Hello,

    I'm sure it's very easy to solve, but I don't have a lot of time, so I even don't search for the solution by myself.

    So, mysql query breaks when the sign ' comes to the sentence. How is it possible to make these signs available with mysql query?

    My mysql_query variable is described like that:
    PHP Code:
    $mysql_query "INSERT INTO `table` (`id` ,`title` ) VALUES (NULL , '$sentence')"
    Thank you for your help!
    http://www.php.net/manual/en/functio...ape-string.php

    best regards

  • Users who have thanked oesxyl for this post:

    withoutnick (05-04-2011)


  •  

    Posting Permissions

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