1 Attachment(s)
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
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
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.
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 ;)
Re: MYSQL & Php Search "no results found" everytime ??
I figured out what the <hr/> tag does... it just adds a straight line.
Re: MYSQL & Php Search "no results found" everytime ??
If you were to put the detail here into a console, it would probably fail:
Quote:
$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