Replace links in posts ? VB Forum

Discussion in 'MySQL' started by crazygirl, Jan 21, 2009.

  1. #1
    I have quite a few people that post images with links that point to usercash - is there a query or update that can replace everything in a tag that contains usercash.com in ...e numbers change in every post. Thanks.
     
    crazygirl, Jan 21, 2009 IP
  2. druidelder

    druidelder Peon

    Messages:
    285
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I assume it is a MySQL database. What version of MySQL is it? That might make a huge difference.
     
    druidelder, Jan 28, 2009 IP
  3. grikis

    grikis Banned

    Messages:
    333
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Use curl to get real link!
     
    grikis, Jan 30, 2009 IP
  4. w0tan

    w0tan Peon

    Messages:
    77
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Unfortunately, there's no SQL query that can do this for you. mySQL doesn't support any kind of wildcard or regular expression searching and replacing within queries.

    You would ba able to do this by using a script (php, perl, python, whatever) that selected each row containing "usercash.com", and then used that languages built in pattern matching to replace the string--even the unique number in front--to google, or just remove it altogether.
     
    w0tan, Jan 31, 2009 IP
  5. eViSeRaTe

    eViSeRaTe Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    How many links is quite a few? lol

    Export the DB to your computer, open with Textpad (http://www.textpad.com), and you can do a find and replace with wildcards (*.usercash.com).

    Once done, reimport the DB with BigDump, or phpMyAdmin.

    NOTE: Make a backup before doing anything with your DB!!
     
    eViSeRaTe, Feb 3, 2009 IP
  6. zealus

    zealus Active Member

    Messages:
    70
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #6
     
    zealus, Feb 6, 2009 IP
  7. zealus

    zealus Active Member

    Messages:
    70
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #7
    zealus, Feb 6, 2009 IP
  8. druidelder

    druidelder Peon

    Messages:
    285
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #8
    It allows it in matching and searching, but the replace function does not support it in MySQL. You either have to write a complex SQL statement to extract the exact term you want to replace or you can do it with a PHP/ASP/etc... script.
     
    druidelder, Feb 6, 2009 IP
  9. w0tan

    w0tan Peon

    Messages:
    77
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #9
    w0tan, Feb 6, 2009 IP
  10. zealus

    zealus Active Member

    Messages:
    70
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #10
    Again, I am not sure I understand the problem, but wouldn't the following statement be somewhat of a solution?
    
    UPDATE new_users
    SET
    new_users.user_state = 'active'
    WHERE
    new_users.user_name REGEXP '[1234567890~!@#$%^&*()_+|}{":?><,./;]'
    Code (markup):
     
    zealus, Feb 17, 2009 IP