An easy Mysql question for an experienced programmer

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
mhouldridge
Forum Contributor
Posts: 267
Joined: Wed Jan 26, 2005 5:13 am

An easy Mysql question for an experienced programmer

Post by mhouldridge »

Hi,

I have the following code used for a search box to query my database;

Code: Select all

$result = mysql_query("SELECT * FROM dedicated WHERE customer LIKE '%$search%'");

I need to tweak it so that it incorporates a list box. Here is my tweaked code;

Code: Select all

$result = mysql_query("SELECT * FROM dedicated WHERE '%$list%' LIKE '%$search%'");

As you can see it used both $list and $search. When I echo this within my output script it shows up, but it doesnt appear to work for the query. I dont think mysql is recognising it..

Please help
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

Code: Select all

$result = mysql_query("SELECT * FROM dedicated WHERE $list LIKE '%$search%'");
User avatar
mhouldridge
Forum Contributor
Posts: 267
Joined: Wed Jan 26, 2005 5:13 am

Post by mhouldridge »

that's sorted, thanks!
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

By the way, I hope you're validating these incoming variables in some way. Otherwise it's a teeny bit of a security risk..
Post Reply