Welcome to TalkGraphics.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2017
    Posts
    5

    Question MYSQL & Php Search "no results found" everytime ??

    Hello all,
    I am trying to do a custom search on my website using MYSQL and PHP. I'm new at both. I've successfully created my MySQL database, added a few items to my table and I've also tested that my resultstext.php page can connect to the database by doing a test. I've watched a ton of tutorials and have created some script, but every time it displays "Successful Connection" "no results found for " my search word that I know I input into MySQL database".

    Can anyone please help me figure out what's wrong with the code, so it will find and display my search? I've uploaded my code in a basic text file. I've changed the actual passwords and other sensitive info, but I know the real ones work. I've tried for weeks, but I just don't know coding very well as I'm new at it.

    Thanks so much! --Maggie
    Attached Files Attached Files

  2. #2
    Join Date
    Aug 2000
    Location
    Harwich, Essex, England
    Posts
    21,895

    Default Re: MYSQL & Php Search "no results found" everytime ??

    I've no idea but that <hr/> tag looks out of place. See:

    https://www.w3schools.com/tags/tag_hr.asp
    Egg

    Intel i7 - 4790K Quad Core + 16 GB Ram + NVIDIA Geforce GTX 1660 Graphics Card + MSI Optix Mag321 Curv monitor
    + Samsung 970 EVO Plus 500GB SSD + 232 GB SSD + 250 GB SSD portable drive + ISP = BT + Web Hosting = TSO Host

  3. #3
    Join Date
    Feb 2017
    Posts
    5

    Default Re: MYSQL & Php Search "no results found" everytime ??

    I checked the link you included and I took out the tag and tried it... still no luck... thanks, though.

  4. #4
    Join Date
    Aug 2000
    Location
    Harwich, Essex, England
    Posts
    21,895

    Default Re: MYSQL & Php Search "no results found" everytime ??

    If the tag is required I think it should be <hr> without the backslash. Just a shot in the dark though
    Egg

    Intel i7 - 4790K Quad Core + 16 GB Ram + NVIDIA Geforce GTX 1660 Graphics Card + MSI Optix Mag321 Curv monitor
    + Samsung 970 EVO Plus 500GB SSD + 232 GB SSD + 250 GB SSD portable drive + ISP = BT + Web Hosting = TSO Host

  5. #5
    Join Date
    Feb 2017
    Posts
    5

    Default Re: MYSQL & Php Search "no results found" everytime ??

    I figured out what the <hr/> tag does... it just adds a straight line.

  6. #6
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,747

    Default Re: MYSQL & Php Search "no results found" everytime ??

    If you were to put the detail here into a console, it would probably fail:
    $query = "SELECT * FROM mytablename WHERE";

    foreach ($terms as $each){
    $i++;
    if ($i == 1)
    $query .= "keywords LIKE '%each%' ";
    else
    $query .= "OR keyword LIKE '%each%' ";
    as the result would show "...WHEREkeywords .." and "WHEREOR ..."

    You need to put a space after the WHERE inside the double quotes: $query = "SELECT * FROM mytablename WHERE ";

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

 

 

Tags for this Thread

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
  •