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
    Sep 2002
    Location
    UK
    Posts
    65
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Abbrievation problems :(

    Ok heres my problem

    When i add some text to my database from a form which has an abbrievation in, it fails to run the add query correct. heres and example of what i mean

    i'm, don't basically any word with a ' in. Is there a way to get text to save to the database with this character in, because mysql must be taking the ' as the end of the string.

    Anyone have any ideas on how to solve my little problem

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    In your SQL query, you have to escape "problematic" characters so that the SQL parser understands that they should not be read as a the end of a string value. Example:

    UPDATE tableName SET field = 'don\\'t do that now'

    See how that single quote inside the string is escaped by prepending it with the backslash?

    If you work with PHP together with MySQL, you can (and should) make use of the very helpful function addslashes():

    http://www.php.net/manual/en/function.addslashes.php

  • #3
    New Coder
    Join Date
    Sep 2002
    Location
    UK
    Posts
    65
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Ah right excellent, yeah thats just the thing

    I thought of a solution after i made this post but its a bit cumbersome i seached a string got instanced of the quote and then re-wrote them escaped and then the displaying them i used the explode() function

    didn't quite work right and took ages :E


  •  

    Posting Permissions

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