Results 1 to 10 of 10

Thread: Search

  1. #1
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default Search

    I'm going to need a search script pretty soon for a client.
    He's a dropshipper and wants his items searchable.

    My issue is I don't know how to do this.
    I'm a little new to PHP and with every answer I get on here, I learn a lot.

    Any ideas as to how to go about this?

    Maybe something like, if they search for this, display this code. Then, if they search for this, display this code...
    Or something along those lines?
    Simple and easy?

    Thanks

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Use a database. That's what they're for.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    May 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    No, you could also use flat file, but a database is more secure.

  4. #4
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by cybercoder
    No, you could also use flat file, but a database is more secure.
    A flat file is no less secure, but a database will do all of the leg work for you. Why write code to search through a formatted file instead of using a SELECT SQL statement, which will have pattern matching and regular expressions built-in (though the latter may depend on the DBMS in use)?

    Mike

  5. #5
    Join Date
    May 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Flat file are dependant on text files, and txt files only have a chmod protecting them. On the otherhand, a database has a password and username authentication running from a specific server address.

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Rubbish. Where do you think databases store their data? In a file.
    In fact, if anything, a plain-text file is more secure, because databases generally allow TCP connections.
    "Only" a chmod? I don't know about Windows permissions, but on *n?x that's usually quite sufficient to keep a system secure, unless the attacker has local access.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by cybercoder
    Flat file are dependant on text files, and txt files only have a chmod protecting them.
    If the file system doesn't give a user permission to read or modify the file, then they won't be able to modify it. Simple enough, yes? Furthermore, if the server is given permission to read or modify the file, but configured not to allow remote access[1], then said file can be used by a script, but never directly accessed.

    On the otherhand, a database has a password and username authentication running from a specific server address.
    Databases are far from invulnerable. It's all a matter of configuration; good administration can render a file unreadable to third parties, just as bad administration or programming can leave a database wide open. Neither one is inherently better than the other.


    Quote Originally Posted by Twey
    I don't know about Windows permissions, but on *n?x that's usually quite sufficient to keep a system secure, unless the attacker has local access.
    The only way to access the data and configuration files for MySQL and PostgreSQL here is to log in as the administrator. Both DBMS run under their own, separate accounts (for which both local and remote login is forbidden), and only an administrator is able to traverse into those directories. Finally, database administration is restricted by IP address, and only one user account has full control of the database.

    Secure? I think so.

    Mike


    [1] The use of access controls can be used to effect this protection. Alternatively, the file can be placed outside the DOCUMENT_ROOT directory.

  8. #8
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    It's a fairly complex thing to do, depending on complexity.

    You need to interpret the input into keywords (seperate at spaces), or not... just search the exact phrase, but that will limit results, obviously.

    Then you need to have a matching set of keywords for each possible result. Or have the actual result (text, a list, whatever) act as those keywords.

    Then you need to find which ones match.

    Then you need to display the matching results.

    Overall, it's fairly complex.

    Select statements would work fine, but not if you want anything beyond direct matching between things. If someone searched for "php html" for example and the item in the database was "php" it would not be a match, unless you did some more complex stuff to the input.
    Likewise, "php" would not match "php html" if that was an item. You'd need to seperate those as well.

    Gotta figure out a strategy, then get into coding it.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  9. #9
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    The only way to access the data and configuration files for MySQL and PostgreSQL here is to log in as the administrator.
    True that. I was just pointing out that databases relied on filesystem permissions too
    Select statements would work fine, but not if you want anything beyond direct matching between things. If someone searched for "php html" for example and the item in the database was "php" it would not be a match, unless you did some more complex stuff to the input.
    Likewise, "php" would not match "php html" if that was an item. You'd need to seperate those as well.
    Or unless you used LIKE '%php%' or even REGEXP '\bphp\b'.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  10. #10
    Join Date
    May 2006
    Location
    Cow Planet
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    U can use this simple script.
    Installation is along with it

    http://rapidshare.de/files/21088947/search.zip.html

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
  •