Jump to content

DIY-Forum

Members
  • Posts

    31
  • Joined

  • Last visited

Posts posted by DIY-Forum

  1. Hello again,

     

    I have another question; when I enter the % manually, then it works, why is that?

     

    Like, when I enter solar%panel it finds solar panel, but when i enter solarpanel it dont? why is a manually "wildcard" solar%panel readable but a function inputing solar%panel not readable? :s

     function moreWords($val){$val = str_replace(" ","%", $val);echo $val;}morewords("solar panel");

    will output solar%panel, and should return the same value when sent as a string through the return $val i use?

    but it don't.. I really find it tempting to ask users to enter a % when searching with multiplie words.. though people might find that as an unpleasant user experience?

  2. You could construct the query using a loop. Be very sure that you don't allow any way for people to hack your database using SQL injection.

     

    Ok, then I'll do that! Thank you very much for your quick response :)

     

    I only know of the escape string, and I've heard some people use strip and add slashes, but don't know if I need to do that with esacpe string? do you have any tips?

  3. Hello everyone, I did try to search alot for an answer on this one, but I could not find it anywhere.

     

    I'm trying to have a simple search feature for my site, but I keep getting a blank page when doing a search containing multiplie words "like this"

     

    Tried to work it out with a str_replace but did not do the trick, have done this before, and it does work when just outputing the val as an echo instead of a query, so I'm blank now and appreciate any help! :)

     

    //function for replacing empty space with % function moreWords($val){$val = str_replace(" ","%", $val);return $val;}
    //Query$getCategoriesResults = mysql_query("SELECT * FROM `database`.`forumCategories` WHERE description LIKE '%".moreWords($_GET['search'])."%'");
×
×
  • Create New...