SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2001
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySQL search question

    Hi!

    I'm building a web site statistics script that needs to match the PHP $REFERER variable against a list of search engines I have in a mysql table.

    The table is called "engines":

    id name search
    1 Google .google.
    2 Yahoo .yahoo.
    etc...

    Lets pretend a visitor comes from google and the referer address is http://www.google.com/search?test=1.

    Is there a way to check that referer address against my table of search engines to find the name of the search engine?

    I know you can use "LIKE", as in:

    SELECT name FROM engines WHERE search LIKE "%google%"

    This would return "Google".

    But this doesn't work:

    SELECT name FROM engines WHERE search LIKE "%http://www.google.com/search?test=1%"

    If anyone has any ideas i'd be very appreciative. Thanks!

  2. #2
    chown linux:users\ /world Hartmann's Avatar
    Join Date
    Aug 2000
    Location
    Houston, TX, USA
    Posts
    6,455
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    I think your best bet would be to tear the referrer string down using PHP and then use a LIKE statement to search for something similar in the database.

    I would not use the whole referrer string because like you said, it doesn't work

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2001
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok thanks

  4. #4
    chown linux:users\ /world Hartmann's Avatar
    Join Date
    Aug 2000
    Location
    Houston, TX, USA
    Posts
    6,455
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Let me clarify a little. What you can do is use a regular expression to take out anything before or after the .google. so that you are just left with that... Then you would use the resulting string to search with.


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
  •