Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    37
    Rep Power
    15
    I defined a field name in mysql name1 varchar(30)

    some records in the database have spaces in their names like for example:

    name1 = Kirk Douglas

    When is try to get results out of the database i notice that i have problems(Kirk Douglas) with the spaces.When i insert the name like Kirk-Douglas it is recognized, but i do not want that. How can I solve this problem?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    63
    Rep Power
    15
    Are you saying that the entry in the db is missing a space, the result is missing the space, or that it is unable to find the entry due to the space?

    [This message has been edited by chris22 (edited September 12, 2000).]
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    37
    Rep Power
    15
    unable to find due to the space in the entry
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    63
    Rep Power
    15
    What is the syntax of the query?
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    37
    Rep Power
    15
    SELECT * FROM table WHERE name1='$name1'
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    63
    Rep Power
    15
    That should work. You could try

    SELECT * FROM table WHERE name1 LIKE '%$name1%'
  12. #7
  13. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,648
    Rep Power
    4493
    There's got to be something else wrong, because your query should work, even with the space. How are you putting the data into the database, and where are you getting the data from to put it in there? use mysql_error() to see exactly what kind of error you are getting...

    ---JH
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    37
    Rep Power
    15
    I myself put information in the database , i have full control

    The problem is only in netscape. In both IE and Netscape I get the first five results. IE gives me then the next results, but netscape says "cannot find records on Kirk". The fieldname: name1. Entry is Kirk Douglas".


    Ok when i put for example Kirk-Douglas in the field, netscape gives me the results
    When i get the first results and i go over the next button statusbar:search.php?name1=Kirk Douglas&offset=5, so this should be ok

    [This message has been edited by pepweb (edited September 12, 2000).]

    [This message has been edited by pepweb (edited September 12, 2000).]
  16. #9
  17. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    You need to urlencode() the variable holding the name when you build the link.
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    37
    Rep Power
    15
    You mean put it into a string or something? Can you give an example?
  20. #11
  21. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    9
    Rep Power
    0
    urlencode:

    myVar = "Kirk Douglas";

    urlencodedVar = urlencode(myVar);

    urlencodedVar now has "Kirk+Douglas"

    (php will automagically swap the + for a space, you will never see it)

    so now your query should look like this:

    search.php?name1=Kirk+Douglas&offset=5
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    37
    Rep Power
    15
    ok thanks a lot!! this works!!
  24. #13
  25. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,648
    Rep Power
    4493
    Don't forget to urldecode() on the next page, to get rid of the + before you query the database.
  26. #14
  27. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    SepodatiCreations,

    That is a myth. PHP automatically urldecodes any data passed via the query string.
  28. #15
  29. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    15
    Just an aside really - but how do you put the info in the db? directly / via phpMyAdmin - or you own form ? - if you use your own form remember to enclose the value="kirk douglas" or value="<? $var?>" in quotes "!"- otherwise only the part of the string before the space gets posted.

    ------------------
    Simon Wheeler
    FirePages -DHTML/PHP/MySQL
Page 1 of 2 12 Last
  • Jump to page:

Similar Threads

  1. dynamic form field names
    By harwoodspike in forum PHP Development
    Replies: 1
    Last Post: February 1st, 2004, 11:43 AM
  2. Displaying field names
    By Fraudo in forum PHP Development
    Replies: 2
    Last Post: January 27th, 2004, 03:24 PM
  3. normalised design causing problems displaying results
    By emilyb in forum MS SQL Development
    Replies: 14
    Last Post: January 21st, 2004, 07:02 PM
  4. Replies: 0
    Last Post: January 19th, 2004, 06:03 AM
  5. SQL statement to uniquify results based on one field
    By AaronMcMahon in forum Database Management
    Replies: 4
    Last Post: January 13th, 2004, 09:20 AM

IMN logo majestic logo threadwatch logo seochat tools logo