SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict manipura's Avatar
    Join Date
    Apr 2001
    Location
    Calgary,AB
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Killing white/blank space in DB

    I have a database with about 18 fields and almost every field in every
    record has white/blank space at the end of it. Some even have some
    at the start.

    Now the problem:

    trim() doesn't strip non breaking space (&nbsp)

    and there are a few of them in the fields.

  2. #2
    Fully Sweet Car noddy's Avatar
    Join Date
    Aug 2002
    Location
    Perth, Western Australia
    Posts
    759
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Two things you can try.

    1) at the command line use the mysql optimize function to optimize the database\table your concerned with.

    2) referer to the mysql website their is much information their which can help you. www.mysql.com

  3. #3
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Another option (after you've done noddy's to fix the existing data) is to use str_replace to remove blank spaces on input.

    Also, trim will remove any character, you can set the characters to be removed in the second parameter.

  4. #4
    SitePoint Member
    Join Date
    Jan 2003
    Location
    Australia
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just a question regarding optimization.
    Is it possible to optimize a db/table other than using phpMyAdmin or command line?
    Can it be done with php?

  5. #5
    Super Ninja Monkey Travis's Avatar
    Join Date
    Dec 2001
    Location
    Sioux City, Iowa
    Posts
    691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you know the command for it you should just be able to use this:
    PHP Code:
    mysql_query ('blah'); 
    Travis Watkins - Hyperactive Coder
    My Blog: Realist Anew
    Projects: Alacarte - Gnome Menu Editor

  6. #6
    SitePoint Member
    Join Date
    Jan 2003
    Location
    Australia
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers Trav,
    I'd wondered if that would work but had never tried it as all I've ever read about it concerned phpMyAdmin or the command line.
    I'll give it a go.

    Thanks again.


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
  •