Hi guys,
I am still new in calling functions in php.
I wondered if anyone could show me an example in details on how to call this funciton 
in an application??
[PHP]

<?php
 
$dbinfo = array("host"     => "localhost", 
                "user"     => "", 
                "pass"     => "", 
                "database" => "search_engine", 
                "keywords" => "keywords_list", 
                "desc"     => "page_data"); 

function search($db, $query_terms) { 

   $matches = array(); 

   $db_h = mysql_connect($db['host'], 
        $db['user'], 
        $db['pass']); 

    if (!$db_h) { 

$error = "Couldn't connect to MySQL database [" . 
    mysql_errno() . "]: "; 
        $error .= mysql_error(); 

        return $error; 
    } 

    mysql_select_db($db['name']);

$keywords = explode(' ', addslashes(strtolower($query_terms))); 
$reg_ex = "[(" . implode(")(", $keywords) . ")]"; 

$query = "SELECT count(keywords_list.key_id) as score, 
page_data.url as url,    page_data.title as title, 
                       page_data.desc as desc 
                  FROM keywords_list, page_data 
                 WHERE (page_data.page_id = 
  keywords_list.page_id) 

while($row = mysql_fetch_array($query_h)) { 

      array_push($matches, $row); 

   } 

    return $matches; 
} 
?> 
                   AND (keywords_list.keys REGEXP 
       $reg_ex) 
              GROUP BY keywords_list.page_id 
              ORDER BY score DESC"; 

   $query_h = mysql_query($db_h, $query); 

   if(!$query_h) { 

      $error = "Couldn't execute query [" . 
mysql_errno($dbh) . "]: "; 
        $error .= mysql_error($dbh); 

        return $error; 

   } 
?>


[/PHP]



---------------------------------
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now

Reply via email to