|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today! |
|
#1
|
|||
|
|||
|
Matt Wade Tutorial Errors
Hi..
Am just working through Matt Wades tutorial on Creating a Search Application, but Im receiving errors with the code below..Depending on the input within the input box.. thanks heaps... /////////// the errors are Warning: array_walk(): The argument should be an array in C:indigoperlapachehtdocssearchsearchclass.php on line 70 Warning: arsort() expects parameter 1 to be array, null given in C:indigoperlapachehtdocssearchsearchclass.php on line 84 Warning: array_keys(): The first argument should be an array in C:indigoperlapachehtdocssearchsearchclass.php on line 85 Warning: array_walk(): The argument should be an array in C:indigoperlapachehtdocssearchsearchclass.php on line 86 //////////////// the code is <?php require('dbclass.php'); class Search { var $_db; var $_searchterms; var $_numterms; function Search($keywords) { $this->_db = new DB_Class('host', 'user', 'pass'); if (!get_magic_quotes_gpc()) { $keywords = addslashes ($keywords); } $this->_searchterms = explode(' ', $keywords); $this->_numterms = count($this->_searchterms); } function doSearch() { $match = "keywords.keyword in ('" . $this->_searchterms[0] . "'"; for ($i = 1; $i < $this->_numterms; $i++) { $match .= ", '" . $this->_searchterms[$i] . "'"; } $match .= ")"; $query = "SELECT urls.url, count(*) as counter " . "FROM urls, keywords " . "WHERE $match " . "AND keywords.url_id = urls.id " . "GROUP BY keywords.url_id " . "ORDER BY counter DESC"; $result = $this->_db->fetch($query); if (count($result) > 0) $return = $result; else $return = FALSE; return $return; } function _highpercent(&$item, $key, $array) { if ($item < 60) unset($array["$key"]); } function _sla****(&$item, $key) { $item = addslashes($item); } function doFuzzy() { $match = "LEFT(keyword,1) in ('" . substr($this->_searchterms[0], 0, 1) . "'"; for ($i = 1; $i < $this->_numterms; $i++) { $match .= ", '" . substr($this->_searchterms[$i], 0, 1) . "'"; } $match .= ")"; $query = "SELECT DISTINCT(keyword) FROM keywords " . "WHERE $match"; $keywords = $this->_db->fetch($query); reset($this->_searchterms); foreach ($this->_searchterms as $term) { foreach ($keywords as $keyword) { $word = $keyword['keyword']; similar_text($term, $word, $matches["$term"]["$word"]); } array_walk ($matches["$term"], array($this, '_highpercent'), $matches["$term"]); } if($this->_numterms > 1) { $merge = '$merged = array_merge($matches["' . $this->_searchterms[0] . '"]'; for ($i = 1; $i < $this->_numterms; $i++) { $merge .= ', $matches["' . $this->_searchterms[$i] . '"]'; } $merge .= ');'; eval ($merge); } else { $merged = $matches[$this->_searchterms[0]]; } arsort($merged); $search = array_keys($merged); array_walk($search, array($this, '_sla****')); $match = "keywords.keyword in ('" . $search[0] . "'"; $numwords = count ($search); for ($i = 1; $i < $numwords; $i++) { $match .= ", '" . $search[$i] . "'"; } $match .= ")"; $query = "SELECT urls.url, keywords.keyword, " . "count(*) as counter " . "FROM urls, keywords " . "WHERE $match " . "AND keywords.url_id = urls.id " . "GROUP BY keywords.url_id, keywords.keyword " . "ORDER BY counter DESC"; $result = $this->_db->fetch($query); if (count($result) > 0) $return = $result; else $return = FALSE; return $return; } } ?> |
|
#2
|
|||
|
|||
|
Message Moved
Thread moved from 'PHP Coding' to 'Tutorials' by tkarkkainen.
Reason: Tutorial question |
|
#3
|
|||
|
|||
|
RE: Matt Wade Tutorial Errors
I am having the same errors. Also, although it is kind of a useful starting point the harvesting is very minor. It seems to only grab the page title and navigation or something. The page is a XHTML 1.0 strict tableless design so it shouldn't be missing the content and its a blog so there is plenty to put into the keywords table.
Any clues on why the error comes up would be appreciated... thanks |
|
#4
|
|||
|
|||
|
RE: Matt Wade Tutorial Errors
Hi all, I am having the same exact errors. For some reason when you search for something and q,z,x,j,k,4,5,7,8,9 and 0 is the first letter/number in your search term it gives that error.
I can't for the life of me figure it out. MATTTTT!!!!!!!!! Errors are the same with all of those: Warning: array_walk(): The argument should be an array in /home/virtual/site267/fst/var/www/html/searchclass.php on line 70 Warning: arsort() expects parameter 1 to be array, null given in /home/virtual/site267/fst/var/www/html/searchclass.php on line 84 Warning: array_keys(): The first argument should be an array in /home/virtual/site267/fst/var/www/html/searchclass.php on line 85 Warning: array_walk(): The argument should be an array in /home/virtual/site267/fst/var/www/html/searchclass.php on line 86 |
![]() |
| Viewing: Codewalkers Forums > Other > Tutorials > Matt Wade Tutorial Errors |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|