SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast itportal's Avatar
    Join Date
    Sep 2005
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy strpos() not working ?!

    Hello,

    I have strange problem. I use a strpos function and when I start it, it works fine on my local server. But when I upload the file to my US server, it doesn't work well and always returns 0.

    Notice that I use strpos() to search in cyrillic strings. When I don't use cyrillic string, it works well on both servers.

    Isn't strpos() binary-safe? What should I do in order to make it work?

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    post the minimum amount of code needed to demonstrate your problem.

  3. #3
    SitePoint Enthusiast itportal's Avatar
    Join Date
    Sep 2005
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nothing special:


    $pos = 0;
    if(strpos(strtolower($R["body"]), strtolower($q)) > 100) $pos = strpos(strtolower($R["body"]), strtolower($q)) - 100;
    if($pos < 0) $pos = 0;


    .. and $pos is always 0

  4. #4
    SitePoint Addict Kokos's Avatar
    Join Date
    Nov 2005
    Location
    The Netherlands
    Posts
    205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The first if statement doesn't get closed, so that's a problem.

    Taking over the web one pixel at a time.
    Currently working @ CodeCreators

  5. #5
    SitePoint Enthusiast itportal's Avatar
    Join Date
    Sep 2005
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nope .. it's closed .. I said it works on my local server

  6. #6
    SitePoint Enthusiast itportal's Avatar
    Join Date
    Sep 2005
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any ideas?

  7. #7
    SitePoint Enthusiast itportal's Avatar
    Join Date
    Sep 2005
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Found out what the problem is strtolower doesn't work well on my US server with cyrillic characters

  8. #8
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    mb_strtolower and mb_strpos perhaps?

    Those are the equivalent functions with multibyte character set support.

  9. #9
    SitePoint Enthusiast itportal's Avatar
    Join Date
    Sep 2005
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes ... my PHP is < 4.3.0, but managed to fix it with setlocale and I used the simple strtolower


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
  •