-
-
Save gavinblair/723791 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//updated to fit http://drupal.org/writing-secure-code | |
function ajax_autocomplete(){ | |
$q = $_GET['z'].'%'; | |
$limit = intval($_GET['limit']); | |
$sql = "select distinct title from node where status = 1 AND (type = 'product' OR type = 'model_documentation') AND title LIKE '%s' order by title limit %d"; | |
$result = db_query($sql, $q, $limit); | |
while($row = db_fetch_array($result)) { | |
echo "{$row['title']}\n"; | |
} | |
exit(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice. Gave it a shot, worked but I had to change %s to '%s'
Your version fits better with http://drupal.org/writing-secure-code