$query = 'SELECT * FROM `products` WHERE `descript` LIKE (\'%girl%\')';
If the code above is written into the php script and I run through the browser: mysite.com/search.php
I get a list of products with the word "girl" in the 'descrip'tion
If I change the code to this:
$query = 'SELECT * FROM `products` WHERE `descript` LIKE (\'%.$newSearch.%\')';
or this:
$query = 'SELECT * FROM `products` WHERE `descript` LIKE (\'%.$_GET["newSearch"].%\')'
then go here:
mysite.com/search.php?newsearch=girl
I get no errors but I get no results either, just blank
any help or explanation would be great...
What's the difference, and is it possible?
Moderator: General Moderators
-
NATASHALUX55
- Forum Newbie
- Posts: 3
- Joined: Thu Jun 25, 2009 5:52 am
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: What's the difference, and is it possible?
Try this...
NB: Dont forget to protect your database!
Code: Select all
$query = 'SELECT * FROM `products` WHERE `descript` LIKE "%'.$_GET["newSearch"].'%"';-
coolpositive
- Forum Newbie
- Posts: 4
- Joined: Sat Jun 07, 2008 6:13 am
Re: What's the difference, and is it possible?
Hi NATASHALUX55
when you write query in php then echo theat query on page then copy that query and and direct paste on sql mode of phpmyadmin or what every use your database.
you got the exect error what is the problem in your query.
when you write query in php then echo theat query on page then copy that query and and direct paste on sql mode of phpmyadmin or what every use your database.
you got the exect error what is the problem in your query.
-
NATASHALUX55
- Forum Newbie
- Posts: 3
- Joined: Thu Jun 25, 2009 5:52 am
Re: What's the difference, and is it possible?
Well I got results... But it was all products that was listed...jaoudestudios wrote:Try this...NB: Dont forget to protect your database!Code: Select all
$query = 'SELECT * FROM `products` WHERE `descript` LIKE "%'.$_GET["newSearch"].'%"';
does LIKE %***% not work like that? Anyway thanks for your help so far- I was happy just to see something.
I have to entries I'm using as my test, they both have cuddly in the descript and 1 has boy and 1 has girl in the descript.
http://giftsbyfairfields.com/newsearch. ... hTerm=girl
has no effect on narrowing the search.
I'm thinking maybe it's not as simple as that and that's why I'm having issues?
again- thanks
-
mattpointblank
- Forum Contributor
- Posts: 304
- Joined: Tue Dec 23, 2008 6:29 am
Re: What's the difference, and is it possible?
You capitalised the S in 'newSearch' in the code, but not in the URL.
-
NATASHALUX55
- Forum Newbie
- Posts: 3
- Joined: Thu Jun 25, 2009 5:52 am
Re: What's the difference, and is it possible?
it worked... one more question...
WHY DIDN'T I COME HERE SOONER???
Thanks a whole bunch, I hope one day to return the favor to someone who's stuck.
WHY DIDN'T I COME HERE SOONER???
Thanks a whole bunch, I hope one day to return the favor to someone who's stuck.