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

Thread: escape

  1. #1
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,963
    Thanks
    120
    Thanked 76 Times in 76 Posts

    escape

    Code:
    update comments c
    set c.`comment` = REPLACE('[URL]','[URL href = \'')
    Why this does not work ? Problem is here: \'' obviously.
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,567
    Thanks
    78
    Thanked 4,384 Times in 4,349 Posts
    Ummm...are you SURE you want that???

    If the comment was (example)
    Code:
    Look here: [ URL]http://www.zoo.com[/URL]
    for more information
    Then that replacement would give you
    Code:
    Look here: [ URL href='http://www.zoo.com[/URL]
    for more information
    Surely that is not what you are after???

    But in any case, that's the wrong syntax for REPLACE in MySQL.

    http://dev.mysql.com/doc/refman/5.5/...nction_replace

    And then it works. Ugly, but works.
    Code:
    mysql> select * from comments;
    +-----------------------------------+
    | comment                           |
    +-----------------------------------+
    | Look here: {URL}www.zoo.com{/URL} |
    +-----------------------------------+
    1 row in set (0.00 sec)
    
    mysql> update comments set comment = REPLACE(comment,'{URL}','{URL href=\'');
    Query OK, 1 row affected (0.00 sec)
    Rows matched: 1  Changed: 1  Warnings: 0
    
    mysql> select * from comments;
    +-----------------------------------------+
    | comment                                 |
    +-----------------------------------------+
    | Look here: {URL href='www.zoo.com{/URL} |
    +-----------------------------------------+
    1 row in set (0.00 sec)
    (I used { } because this forum won't let me override the meaning of [ URL] (without the space), but you can see it works.
    Last edited by Old Pedant; 12-11-2012 at 02:20 AM.
    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.

  • Users who have thanked Old Pedant for this post:

    BubikolRamios (12-11-2012)

  • #3
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,963
    Thanks
    120
    Thanked 76 Times in 76 Posts
    Yes exactly that. Thanks.


    I had a 'tool tip hint' on client that was too small, and I concluded there are only 2 params.
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search


  •  

    Posting Permissions

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