Page 1 of 1

*Solved*SQL syntax error in search code

Posted: Tue Apr 19, 2005 7:19 am
by mohson
Can anyone see anything wrong with the sql syntax in this code keep getting error message, for example if I enter 'a' in the search box I get the error message
Error in query: You have an error in your SQL syntax near 'WHERE name LIKE 'a%'' at line 5

Code: Select all

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

 $query = 	"SELECT 
		 name, organisation,website,stu_id
		 FROM studentwebsites ORDER BY organisation 

WHERE name LIKE '$formVars[name]%'";

Posted: Tue Apr 19, 2005 7:22 am
by feyd
ORDER BY clauses come after WHERE clauses.