Tutorials
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOtherTutorials

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today!
  #1  
Old October 22nd, 2004, 02:39 PM
mrgee mrgee is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 11 mrgee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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;
}
}
?>

Reply With Quote
  #2  
Old October 22nd, 2004, 03:51 PM
System System is offline
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Posts: 665 System User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Message Moved

Thread moved from 'PHP Coding' to 'Tutorials' by tkarkkainen.

Reason: Tutorial question

Reply With Quote
  #3  
Old February 25th, 2005, 10:03 PM
Porco Porco is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Hobart, Tasmania, Australia
Posts: 158 Porco User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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

Reply With Quote
  #4  
Old August 21st, 2005, 05:10 AM
mr_banks mr_banks is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 1 mr_banks User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Codewalkers ForumsOtherTutorials > Matt Wade Tutorial Errors


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway