SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Aug 2004
    Location
    Utah, USA
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Database Cleanup

    Somebody uploaded some bad data (serialized php) into my database and I'm trying to figure out how to clean it up using a MySQL query.

    The bad data looks like this:
    a:1:{i:0;s:7:"Robert";}

    I've tried this pair of queries but my database keeps giving me the all too familiar, "You have an error in your SQL syntax;"
    UPDATE `profile_values` SET `value` SUBSTRING_INDEX(`value`, '"', -2) WHERE fid = 1 AND uid = 22;
    UPDATE `profile_values` SET `value` TRIM(TRAILING '";}' FROM `value`) WHERE fid = 1 AND uid = 22;

    I built these queries using these examples from the MySQL reference:

    mysql> SELECT SUBSTRING_INDEX('www.mysql.com', '.', -2);
    -> 'mysql.com'

    mysql> SELECT TRIM(TRAILING 'xyz' FROM 'barxxyz');
    -> 'barx'

    Any direction anyone can give would be greatly appreciated.
    Kevin

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,401
    Mentioned
    147 Post(s)
    Tagged
    4 Thread(s)
    You're missing a =
    Code:
    SET `value` =

  3. #3
    SitePoint Zealot
    Join Date
    Aug 2004
    Location
    Utah, USA
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Doh!
    Thanks guido2004


Bookmarks

Posting Permissions

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