Jump to content

Archived

This topic is now archived and is closed to further replies.

scman

Passing a php form variable to a mysql statment

Recommended Posts

So I have this data base which has the same names in it as form options that I want to match at a users request. I need to pass the variable from php to mysql but I am stuck trying to do it


I tried this

elseif(!$HTTP_GET_VARS['CS'] == "" and !$HTTP_GET_VARS['KS'] == ""){

$result = mysql_db_query("staffdir","SELECT * from Technology WHERE SELECT * FROM technology where keywords like {$HTTP_GET_VARS[$KS]} ORDER BY last_name");


Can some one point me in the right direction

Share this post


Link to post
Share on other sites
Try this:

SELECT * FROM Technology WHERE keywords like '%$HTTP_GET_VARS[$KS]%' ORDER BY last_name

Share this post


Link to post
Share on other sites
Don't use $HTTP_GET_VAR, use the superglobal array $_GET. This is assuming that the method in your form is "GET" or not mentioned. If it is "POST", use the array $_POST.

If you are still having problems, please post the source for your form and your script.

Ken

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.