Valid regex (old?) code in a query??
Posted: Wed Mar 22, 2006 5:06 pm
I'm trying to make a simple search function that takes a string of user input and returns matches based on the number of keywords that match.
I am basing this on code that is about 5 years old - is it still valid as I am having trouble getting the REGEX to work? I am using PHP Version 4.4.2.
Thanks in advance
rj
I am basing this on code that is about 5 years old - is it still valid as I am having trouble getting the REGEX to work? I am using PHP Version 4.4.2.
Code: Select all
function search($query_terms){
$tags = explode(' ', addslashes(strtolower($tags)));
$reg_ex = "[(" . implode(")(", $tags) . ")]";
$sql_get_tags =mysql_query( "SELECT count(f_tags.tag_id) as score,
$tag_link.user_id as f_user_id
FROM f_tags, $tag_link
WHERE ($tag_link.tag_id = f_tags.tag_id)
AND (f_tags.tag REGEXP $reg_ex)") or die (mysql_error());
while($get_tags = mysql_fetch_array($sql_get_tags)) {
print_r($get_tags);
}
}Thanks in advance
rj