Jump to content


Passing a php form variable to a mysql statment

  • Please log in to reply
2 replies to this topic

#1 scman

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 21 April 2006 - 05:00 AM

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

#2 wisewood

  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 21 April 2006 - 08:45 AM

Try this:

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

wisewood: proven fact, I am both wise, and wooden.

#3 kenrbnsn

  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 21 April 2006 - 01:38 PM

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.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users