Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    New Coder
    Join Date
    Oct 2002
    Location
    California
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Making PHP for search engine...

    If anyone can help I'd appreciate it, I'm trying to make a search engine in PHP. I had several questions.

    I'm a bit confused about "get" should I use this instead of "post"?

    Should the results be stored in an array? I wanted to make 25 results show per page, with a <<Next and <<Back button.

    I'm going to try and make each result "row" alternating colors (Like these forums) Is there an easier way to do this than write seperate HTML for two rows instead of just one?

    Any help would be appreciated, I'm trying to get this thing done ASAP, and I'm a virtual newbie to PHP

    Thanks!

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    I wouldn't recommend trying to write a full out program in PHP right from the start if you are new to PHP and especially in a hurry. That's a recipe for disaster.

    Use a free ready made script if you are in a hurry.

    http://www.hotscripts.com/PHP/Script...earch_Engines/

    And yes you can use the "get" method if you wish for the visitors to be able to bookmark the search results so they can go back to them later. The get method simply adds the values passed in the URL.
    Last edited by Spookster; 01-27-2003 at 05:22 AM.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    New Coder
    Join Date
    Oct 2002
    Location
    California
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Spookster, I was wondering about that

    Hoping I wouldn't need a complicated script to let people bookmark results etc, didn't realize it was that simple.

  • #4
    New Coder
    Join Date
    Oct 2002
    Location
    California
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok this may be a dumb question...

    When I test what I have so far, say I type in "internet", and press search...

    It will take me to my search.php and say:

    Sorry, there were no results for \"internet\"

    Is there any way to make it display what I typed in, without the backslash code?

    Thanks

  • #5
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Originally posted by nickbarresi
    Is there any way to make it display what I typed in, without the backslash code?

    Yes of course there is
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #6
    Regular Coder
    Join Date
    May 2002
    Location
    London, England
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    so helpful spook (don't worry about him... he's getting old )

    Edit the code for that page, and use the stripslashes() function

    www.php.net/stripslashes for more info

    Jee
    Jeewhizz - MySQL Moderator
    http://www.sitehq.co.uk
    PHP and MySQL Hosting

  • #7
    New Coder
    Join Date
    Oct 2002
    Location
    California
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ah, thank you that worked perfectly

  • #8
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Originally posted by Jeewhizz
    so helpful spook (don't worry about him... he's getting old )

    Edit the code for that page, and use the stripslashes() function

    www.php.net/stripslashes for more info

    Jee
    Hey there cheezwhiz you better respect your elders! Didn't your mum(im assuming that's how you say mom in england) teach you nothing?

    I was simply answering the question. If it were asked...."How do I...?" then I would have answered how.

    And get out of my forum before I zap you with my mod gun. ~
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #9
    New Coder
    Join Date
    Oct 2002
    Location
    California
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok guys new question,

    I'm adding a column "hits" to my database, which will keep track of how many times a particular link has been clicked through.
    (Each row in database are links to sites... title, description, and URL, and hits)

    Is there any way I can accomplish this in PHP? And if so, could you explain!

    So in english:

    When link clicked, add 1 to "hits" where url = link....or something

    If I had a PHP/English dictionary, I'd be set, but I don't, so any help is greatly appreciated !

  • #10
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Make a redirecting script that serves as an intermediary layer between your list of URLs and the target site. You pass the URL to be later send to as a GET parameter to the redirecting script, which does nothing else than make a quick connect to your database, and updates the "hits" value associated with that URL. After that, you redirect with the

    header("Location: " . $absoluteURL);

    function. That's it.

  • #11
    New Coder
    Join Date
    Oct 2002
    Location
    California
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Mordred

    But I'm a bit confused,

    What equals the $absoluteURL?

    Also, what actually re-directs the page? The header function?

    Thanks
    Last edited by nickbarresi; 01-28-2003 at 11:43 PM.

  • #12
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by nickbarresi
    What equals the $absoluteURL?
    IIRC the specifications for HTTP require the URL of a "Location" response header to be an absolute URL. Most clients (aka browsers) are capable of resolving a relative URL, so you might not notice "breaching" the specs, but they are not required to do so. And to answer your question ():

    An absolute URL contains the protocol and the host name, like

    http://www.codingforums.com/dir/page.html

    Whereas a relative URL is anything that's applied relatively to a host name, like

    page.html
    dir/page.html
    ../anotherDir/page2.html
    ../././../.././dir/../dir/foo.php

    ...so the actual URL depends on the point from where you resolve this path, thus it is an relative URL. If you really want to know more about it you can read the full specs at rfc-editor.org, but unless you're either very curious about the underlying technology or enjoy reading car insurance policies, you might find those RFCs a little boring... you have been warned.

    Also, what actually re-directs the page? The header function?
    Hmmh... erh... well... it's... you, the developer.
    No seriously, your PHP script sort-of triggers the redirection, but the actual process of fetching another page is carried out by the client (aka browser). That's an important issue to know, unfortunately you see sometimes code samples like this:

    PHP Code:
    if ( !userIsAuthorized() ) {
    // redirect the cracker to the login screen
    header("Location: " $loginPage);
    }  
    // <- don't do this 
    which misses an essential part - to include a die() or exit() statement after the redirection to terminate the script ultimately.
    Because otherwise someone could easily build a HTTP client that does not act on a HTTP Location header, and if sensible data is printed directly after an if statement like the above, the home-made client would receive it and by doing this circumvent your carefully constructed security measures.
    Last edited by mordred; 01-29-2003 at 12:18 AM.

  • #13
    New Coder
    Join Date
    Oct 2002
    Location
    California
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the explanation mordred

    But what's up with the closing curly brace? Does your comment mean don't do it?

    And if so, why not?

    TIA..

  • #14
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hmh, my comment seems to add confusion instead of clearing it. What I meant was this:

    PHP Code:
    // bad!
    if ( !userIsAuthorized() ) {
    header("Location: " $loginPage);

    compared to this:

    PHP Code:
    // good!
    if ( !userIsAuthorized() ) {
    header("Location: " $loginPage);
    exit; 
    // <- that's what's been missing in the bad example


  • #15
    New Coder
    Join Date
    Oct 2002
    Location
    California
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the help Mordred, I have a new question that should be easy to answer...

    I have 5 columns in my database...Title, Description, URL, Hits, and Notes.

    Now when I do a:
    $row=mysql_fetch_row($result);

    This happens....

    $row[0] is the title of the first site
    $row[1] is the description of the first site
    $row[2] is the URL of the first site....

    I'm a bit confused here, how do I call the title, description, and URL automatically as a 'set' without having to write out each one?

    Would it be $row[$title], etc... or something???

    TIA

    EDIT: NEVERMIND, I figured it out, thanks
    Last edited by nickbarresi; 01-30-2003 at 05:01 PM.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •