Page 1 of 1
What's the difference, and is it possible?
Posted: Thu Jun 25, 2009 7:43 am
by NATASHALUX55
$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...
Re: What's the difference, and is it possible?
Posted: Thu Jun 25, 2009 7:51 am
by jaoudestudios
Try this...
Code: Select all
$query = 'SELECT * FROM `products` WHERE `descript` LIKE "%'.$_GET["newSearch"].'%"';
NB: Dont forget to protect your database!
Re: What's the difference, and is it possible?
Posted: Thu Jun 25, 2009 7:55 am
by coolpositive
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.
Re: What's the difference, and is it possible?
Posted: Thu Jun 25, 2009 8:07 am
by NATASHALUX55
jaoudestudios wrote:Try this...
Code: Select all
$query = 'SELECT * FROM `products` WHERE `descript` LIKE "%'.$_GET["newSearch"].'%"';
NB: Dont forget to protect your database!
Well I got results... But it was all products that was listed...
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
Re: What's the difference, and is it possible?
Posted: Thu Jun 25, 2009 9:05 am
by mattpointblank
You capitalised the S in 'newSearch' in the code, but not in the URL.
Re: What's the difference, and is it possible?
Posted: Thu Jun 25, 2009 9:12 am
by NATASHALUX55
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.
