Jump to content


Photo

[b]Like function in select statement[/b]


  • Please log in to reply
2 replies to this topic

#1 hecheng

hecheng
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 15 July 2003 - 01:56 AM

the following is my mysql_query statement

$result=mysql_query(\"select * from elementary where Location like \'%\".$_POST[\'textfield\'].\"%\'\", $mylink);

If I input inToronto for my search string,
the result does not output the records that have
Toronto in them.

could anybody explain how i can fix the problem?

Thank you!!!



:D

#2 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 15 July 2003 - 02:09 AM

i\'ve had difficulties including $_POST variables in mysql queries before. see if this helps:

$search = $_POST[\'textfield\'];$result = mysql_query("SELECT * FROM elementary WHERE location LIKE \'%$search%\'", $mylink);

cheers

#3 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 15 July 2003 - 04:26 AM

you can also enclose the POST in braces like so:

$result = mysql_query(\\\"SELECT * FROM elementary WHERE location LIKE \'%{$_POST[\'textfield\']}%\'\\\", $mylink);


Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users