[support] Place holders in SQL query

Greg Knaddison greg at growingventuresolutions.com
Mon Apr 11 15:49:44 UTC 2011


On Sun, Apr 10, 2011 at 11:05 PM, Warren Vail <warren at vailtech.net> wrote:
> Not sure what you mean by generic, and never used the db_placeholders
> function, but this should work;
>
> $skillnames = array("PHP", "HTML","SQL");
> $tblname = "resubmt_skills";
> $query = sprintf("SELECT skillid FROM %s WHERE skillname in ('%s')",
> $tblname, "'".implode("', '",$skillnames)."'");
> //execute and fetch query results here
>
> not real elegant, but nothing is as elegant as the solution that works
> and maintainers can understand.

This may work, but is _wrong_.

Please read

http://heine.familiedeelstra.com/a-security-vulnerability-waiting-to-happen

Thanks,
Greg

-- 
Greg Knaddison | 720-310-5623 | http://growingventuresolutions.com
http://masteringdrupal.com - Videos and Tutorials


More information about the support mailing list