Forum Moderators: open

Message Too Old, No Replies

Searching with LIKE

not working with variable

         

FromBelgium

2:10 pm on Feb 10, 2006 (gmt 0)

10+ Year Member



I try to return names starting with "A" from a MySQL database.

When I add LIKE 'A%' in the query it works, but when I first define the variable $letter="A" and then use LIKE '$letter%' it returns all values, not only those starting with "A". How can I use a variable with LIKE?

UPDATE:
Problem solved in the meantime. Stupid mistake: I put "$letter" in query string instead of "letter".

coopster

9:24 pm on Feb 13, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



FromBelgium,

Make sure you put "letter" in the query string instead of "$letter".

Just kidding ;)
Glad you got it sorted.