Page 1 of 1

[SOLVED] Search query

Posted: Mon Feb 21, 2005 10:39 am
by mohson
The query below works fine in my system up to this point - now when implementing this query and changing the fields the query has stopped working and I get the following error message:

Error in query: You have an error in your SQL syntax near 'WHERE orgname LIKE 'the text I input%'' at line 5

heres the code:

Code: Select all

foreach($HTTP_POST_VARS as $varname => $value)
        $formVarsї$varname]=$value;

 $query = 	"SELECT 
		 orgname, web_url,sector,org_id,person_id, 
		 notes FROM organisations ORDER BY orgname ASC 

		WHERE orgname LIKE '$formVarsїorgname]%'";
can anyone see anything wrong with this??

Posted: Mon Feb 21, 2005 10:42 am
by markl999
You've got the order a bit muddled ;)

Code: Select all

$query =    "SELECT orgname, web_url,sector,org_id,person_id,
       notes FROM organisations WHERE orgname LIKE '{$formVarsї'orgname']}%' ORDER BY orgname";
I left of ASC as it's the default.

Posted: Mon Feb 21, 2005 10:58 am
by mohson
thank you my man!! simple but effective - I completely forgot that I had ORDER BY in the query - it completely bafflled me.

Thank for pointing it out