Re: trouble with MySQL 'LIKE' command

From: Date: Fri, 04 May 2001 11:17:41 +0000
Subject: Re: trouble with MySQL 'LIKE' command
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-7290@lists.php.net to get a copy of this message
or..... $sql=" ...like '%$name%' "; note $sql="....."; and not '......'; double not single in double quotes your $name is evaluated otherwise you close the string append your variable then apend the rest of the string.... get wat I mean? Xon ----- Original Message ----- From: "r.gelstharp" <r.gelstharp@ntlworld.com> To: <php-windows@lists.php.net> Sent: Saturday, May 05, 2001 2:00 AM Subject: [PHP-WIN] trouble with MySQL 'LIKE' command > I'm trying to implement a search on my site. When the user enters a search > string and pressed the Search button it sends the search string into a > cariable I call searchfor, and I then construct a query that goes something > like : > > "SELECT <whatever> FROM <a table> WHERE product_name LIKE $searchfor..... > > now I know there are things you can do with LIKE such as '%' to search for > an arbitrary number of characters before or after the search string. > > 'WHERE product_name LIKE '%$searchfor%'....' > > this has been causing me problems by outputting mostly rubbish, and then I > find out that the '$' is used in the LIKE command for matching characters > too. > > How do I construct a SELECT statement that uses a PHP variable in the LIKE > clause? > > > > -- > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net > For additional commands, e-mail: php-windows-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.windows (#7290) next »