search error

search error

am 22.11.2006 15:18:16 von Asif Qureshi

--0-525755879-1164205096=:52054
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

search error and code has been posted
--------------------------
Got error 28 from table handler
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home2/wwwabcde/public_html/multipurposechain/searchfuncs.ph p on line 294
Got error 28 from table handlerDisplaying results 1-10 of 4541 matches (12.77 seconds)
Result page: 1 2 3 4 5 6 7 8 9 10 Next


------------------------------------------------------------ --------------------

/*******************************************
********************************************/

error_reporting(E_ALL ^ E_NOTICE);
$include_dir = "include";
include "$include_dir/commonfuncs.php";

function cmp($a, $b) {
if ($a['weight'] == $b['weight'])
return 0;
return ($a['weight'] > $b['weight']) ? -1 : 1;
}
function addmarks($a) {
$a = eregi_replace("[ ]+", " ", $a);
$a = str_replace(" +", "+", $a);
$a = str_replace(" ", "+", $a);
return $a;
}
function makeboollist($a) {
global $entities;
while ($char = each($entities)) {
$a = eregi_replace($char[0], $char[1], $a);
}
$a = trim($a);
$a = eregi_replace(""", "\"", $a);
$returnWords = array();
//get all phrases
$regs = Array();
while (eregi("([-]?)\"([^\"]+)\"", $a, $regs)) {
if ($regs[1] == '') {
$returnWords['+s'][] = $regs[2];
$returnWords['hilight'][] = $regs[2];
} else {
$returnWords['-s'][] = $regs[2];
}
$a = str_replace($regs[0], "", $a);
}
$a = strtolower(eregi_replace("[ ]+", " ", $a));
// $a = remove_accents($a);
$a = trim($a);
$words = explode(' ', $a);
if ($a=="") {
$limit = 0;
} else {
$limit = count($words);
}

$k = 0;
//get all words (both include and exlude)
$includeWords = array();
while ($k < $limit) {
if (substr($words[$k], 0, 1) == '+') {
$includeWords[] = substr($words[$k], 1);
} else if (substr($words[$k], 0, 1) == '-') {
$returnWords['-'][] = substr($words[$k], 1);
} else {
$includeWords[] = $words[$k];
$returnWords['hilight'][] = $words[$k];
}
$k++;
}
//add words from phrases to includes
if (isset($returnWords['+s'])) {
foreach ($returnWords['+s'] as $phrase) {
$phrase = strtolower(eregi_replace("[ ]+", " ", $phrase));
$phrase = trim($phrase);
$temparr = explode(' ', $phrase);
foreach ($temparr as $w)
$includeWords[] = $w;
}
}
foreach ($includeWords as $word) {
if (!($word =='')) {
if (ignoreWord($word)) {
$returnWords['ignore'][] = $word;
} else {
$returnWords['+'][] = $word;
}
}
}
return $returnWords;
}
function ignoreword($word) {
global $common;
global $min_word_length;
global $index_numbers;
if ($index_numbers == 1) {
$pattern = "[a-z0-9]+";
} else {
$pattern = "[a-z]+";
}
if (strlen($word) < $min_word_length || (!eregi($pattern, remove_accents($word))) || ($common[$word] == 1)) {
return 1;
} else {
return 0;
}
}
function search($searchstr, $category, $start, $per_page, $type) {
global $length_of_link_desc,$mysql_table_prefix, $show_meta_description;
//find all sites that should not be included in the result
if (count($searchstr['+']) == 0) {
return null;
}
$wordarray = $searchstr['-'];
$notlist = array();
$not_words = 0;
while ($not_words < count($wordarray)) {
$searchword = addslashes($wordarray[$not_words]);
$query1 = "SELECT link_id from ".$mysql_table_prefix."link_keyword, ".$mysql_table_prefix."keywords where ".$mysql_table_prefix."link_keyword.keyword_id= ".$mysql_table_prefix."keywords.keyword_id and keyword='$searchword'";
echo mysql_error();
$result = mysql_query($query1);
while ($row = mysql_fetch_row($result)) {
$notlist[$not_words]['id'][$row[0]] = 1;
}
$not_words++;
}

//find all sites containing the search phrase
$wordarray = $searchstr['+s'];
$phrase_words = 0;
while ($phrase_words < count($wordarray)) {
$searchword = addslashes($wordarray[$phrase_words]);
$query1 = "SELECT link_id from ".$mysql_table_prefix."links where fulltxt like '% $searchword%'";
echo mysql_error();
$result = mysql_query($query1);
$num_rows = mysql_num_rows($result);
if ($num_rows == 0) {
return null;
}
while ($row = mysql_fetch_row($result)) {
$phraselist[$phrase_words]['id'][$row[0]] = 1;
}
$phrase_words++;
}

if ($category> 0) {
$allcats = get_cats($category);
$catlist = implode(",", $allcats);
$query1 = "select link_id from ".$mysql_table_prefix."links, ".$mysql_table_prefix."sites, ".$mysql_table_prefix."categories, ".$mysql_table_prefix."site_category where ".$mysql_table_prefix."links.site_id = ".$mysql_table_prefix."sites.site_id and ".$mysql_table_prefix."sites.site_id = ".$mysql_table_prefix."site_category.site_id and ".$mysql_table_prefix."site_category.category_id in ($catlist)";
$result = mysql_query($query1);
echo mysql_error();
$num_rows = mysql_num_rows($result);
if ($num_rows == 0) {
return null;
}
while ($row = mysql_fetch_row($result)) {
$category_list[$row[0]] = 1;
}
}
//find all sites that include the search word
$wordarray = $searchstr['+'];
$words = 0;
$starttime = getmicrotime();
while ($words < count($wordarray)) {
$searchword = addslashes($wordarray[$words]);
$query1 = "SELECT distinct link_id, weight from ".$mysql_table_prefix."link_keyword, ".$mysql_table_prefix."keywords where ".$mysql_table_prefix."link_keyword.keyword_id= ".$mysql_table_prefix."keywords.keyword_id and keyword='$searchword' order by weight desc";
$result = mysql_query($query1);
$num_rows = mysql_num_rows($result);
if ($num_rows == 0) {
return null;
}
if ($type == "or") {
$indx = 0;
} else {
$indx = $words;
}

while ($row = mysql_fetch_row($result)) {
$linklist[$indx]['id'][] = $row[0];
$linklist[$indx]['weight'][$row[0]] = $row[1]; }
$words++;
}
if ($type == "or") {
$words = 1;
}
$result_array = Array();

if ($words == 1 && $not_words == 0 && $category < 1) { //if there is only one search word, we already have the result
$result_array = $linklist[0]['weight'];
} else { //otherwise build an intersection of all the results
$j= 1;
$min = 0;
while ($j < $words) {
if (count($linklist[$min]['id']) > count($linklist[$j]['id'])) {
$min = $j;
}
$j++;
}
$j = 0;

$temp_array = $linklist[$min]['id'];
$count = 0;
while ($j < count($temp_array)) {
$k = 0; //and word counter
$n = 0; //not word counter
$o = 0; //phrase word counter
$weight = 1;
$break = 0;
while ($k < $words && $break== 0) {
if ($linklist[$k]['weight'][$temp_array[$j]] > 0) {
$weight = $weight + $linklist[$k]['weight'][$temp_array[$j]];
} else {
$break = 1;
}
$k++;
}
while ($n < $not_words && $break== 0) {
if ($notlist[$n]['id'][$temp_array[$j]] > 0) {
$break = 1;
}
$n++;
}
while ($o < $phrase_words && $break== 0) {
if ($phraselist[$n]['id'][$temp_array[$j]] != 1) {
$break = 1;
}
$o++;
}
if ($break== 0 && $category > 0 && $category_list[$temp_array[$j]] != 1) {
$break = 1;
}
if ($break == 0) {
$result_array[$temp_array[$j]] = $weight;
$count ++;
}
$j++;
}
}//word == 1
$end = getmicrotime()- $starttime;
$results = count($result_array);
if ($results == 0) {
return null;
}
arsort ($result_array);

$keys = array_keys($result_array);
$maxweight = $result_array[$keys[0]];
for ($i = ($start -1)*$per_page; $i $in[] = $keys[$i];
}

if (!is_array($in)) {
$res['results'] = $results;
return $res;
}
$inlist = implode(",", $in);

if ($length_of_link_desc == 0) {
$fulltxt = "fulltxt";
} else {
$fulltxt = "substring(fulltxt, 1, $length_of_link_desc)";
}
$query1 = "SELECT distinct link_id, url, title, description, $fulltxt, size FROM ".$mysql_table_prefix."links WHERE link_id in ($inlist)";
$result = mysql_query($query1);
echo mysql_error();

$i = 0;
while ($row = mysql_fetch_row($result)) {
$res[$i]['title'] = $row[2];
$res[$i]['url'] = $row[1];
if ($row[3] != null && $show_meta_description == 1)
$res[$i]['fulltxt'] = $row[3];
else
$res[$i]['fulltxt'] = $row[4];

$res[$i]['size'] = $row[5];
$res[$i]['weight'] = $result_array[$row[0]];
$i++;
}
if(count($res)!=0)

usort($res, "cmp");


echo mysql_error();
$res['maxweight'] = $maxweight;
$res['results'] = $results;
return $res;
/**/
}
?>



---------------------------------
Sponsored Link

Mortgage rates near 39yr lows. $510,000 Mortgage for $1,698/mo - Calculate new house payment
--0-525755879-1164205096=:52054--

Fwd: Re: search error

am 23.11.2006 06:51:34 von Asif Qureshi

--0-1041419409-1164261094=:76410
Content-Type: multipart/alternative; boundary="0-302503-1164261094=:76410"

--0-302503-1164261094=:76410
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

Here I narrow down the problem.
www.multipurposechain.com

I enter for example search word,
world, Its giving error.

However previously, was giving proper output and search results from tables in database.

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--0-302503-1164261094=:76410
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

Here I narrow down the problem.
 
I enter for example search word,
world, Its giving error.
 
However previously, was giving proper output and search results from tables in database.

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--0-302503-1164261094=:76410--
--0-1041419409-1164261094=:76410
Content-Type: message/rfc822

X-Apparently-To: humanservicesglobe@yahoo.com via 66.196.100.242; Wed, 22 Nov 2006 13:16:17 -0800
X-Originating-IP: [64.233.162.199]
Authentication-Results: mta485.mail.mud.yahoo.com from=gmail.com; domainkeys=temperror (cant get key)
Received: from 64.233.162.199 (EHLO nz-out-0102.google.com) (64.233.162.199)
by mta485.mail.mud.yahoo.com with SMTP; Wed, 22 Nov 2006 13:16:17 -0800
Received: by nz-out-0102.google.com with SMTP id z3so194700nzf
for ; Wed, 22 Nov 2006 13:16:15 -0800 (PST)
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws;
s=beta; d=gmail.com;
h=received:message-id:date:from:user-agent:mime-version:to:c c:subject:references:in-reply-to:content-type:content-transf er-encoding;
b=DiJTyTwaobfaePMBfso0q74ItfNF5V5g2MloBOUcinyaqaWeYEOQqCT+F9 ira7yxQo4tVQK/LVhfnf0Eb0expj78mAsgteJQ+1y+MM+xBoOv0Rq8MGxlnf NU6MDI7m/f6DJUizOfpXX75oaDk0gArHYn8Kx4p8T0yifN76ZTqU0=
Received: by 10.65.253.6 with SMTP id f6mr13193321qbs.1164230175087;
Wed, 22 Nov 2006 13:16:15 -0800 (PST)
Received: from ?10.1.1.11? ( [203.217.18.65])
by mx.google.com with ESMTP id d2sm275365qbc.2006.11.22.13.16.13;
Wed, 22 Nov 2006 13:16:14 -0800 (PST)
Date: Thu, 23 Nov 2006 08:16:12 +1100
From: Chris
User-Agent: Thunderbird 1.5.0.8 (Windows/20061025)
MIME-Version: 1.0
To: Asif Qureshi
CC: php-db@lists.php.net
Subject: Re: [PHP-DB] search error
References: <469776.11141.qm@web58909.mail.re1.yahoo.com>
In-Reply-To: <469776.11141.qm@web58909.mail.re1.yahoo.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Asif Qureshi wrote:
> Got error 28 from table handler
> Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home2/wwwabcde/public_html/multipurposechain/searchfuncs.ph p on line 294
> Got error 28 from table handlerDisplaying results 1-10 of 4541 matches (12.77 seconds)

We're not going to go through all of your code. Narrow down the problem
and we'll be able to help.

--
Postgresql & php tutorials
http://www.designmagick.com/


--0-1041419409-1164261094=:76410
Content-Type: text/plain; charset=us-ascii

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--0-1041419409-1164261094=:76410--

Re: Fwd: Re: search error

am 23.11.2006 07:01:37 von Chris

Asif Qureshi wrote:
> Here I narrow down the problem.

I meant narrow down the problem in your code.

Add

echo "mysql error? " . mysql_error() . "
";

after your mysql_query calls for example.

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Fwd: Re: Fwd: Re: search error

am 23.11.2006 08:22:41 von Asif Qureshi

--0-1490261907-1164266561=:97324
Content-Type: multipart/alternative; boundary="0-929616767-1164266561=:97324"

--0-929616767-1164266561=:97324
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit



Note: forwarded message attached.

---------------------------------
Sponsored Link

Mortgage rates near 39yr lows. $420,000 Mortgage for $1,399/mo - Calculate new house payment
--0-929616767-1164266561=:97324
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: 8bit



Note: forwarded message attached.




Sponsored Link

Mortgage rates near 39yr lows. $420,000 Mortgage for $1,399/mo -

--0-929616767-1164266561=:97324--
--0-1490261907-1164266561=:97324
Content-Type: message/rfc822
Content-Transfer-Encoding: 8bit

Received: from [206.148.72.67] by web58915.mail.re1.yahoo.com via HTTP; Wed, 22 Nov 2006 23:19:40 PST
Date: Wed, 22 Nov 2006 23:19:40 -0800 (PST)
From: Asif Qureshi
Subject: Re: Fwd: Re: [PHP-DB] search error
To: Chris
In-Reply-To: <45653941.2030108@gmail.com>
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="0-1335413932-1164266380=:20650"
Content-Transfer-Encoding: 8bit
Content-Length: 1034

--0-1335413932-1164266380=:20650
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

I have this code already, have a look at this few lines of code, which is already existing.
----------------------------------------------
$query1 = "SELECT distinct link_id, url, title, description, $fulltxt, size FROM ".$mysql_table_prefix."links WHERE link_id in ($inlist)";
$result = mysql_query($query1);
echo mysql_error();
---------------------------------------------
I have experience of past I would get number of responses, and php database mailing list had many members world wide, only single response, why?
----------------------------------------------
In previous code, posted, can you have a look in case tables have been joined properly to respond to query and give proper search results.


Chris wrote:
Asif Qureshi wrote:
> Here I narrow down the problem.

I meant narrow down the problem in your code.

Add

echo "mysql error? " . mysql_error() . "
";

after your mysql_query calls for example.

--
Postgresql & php tutorials
http://www.designmagick.com/



---------------------------------
Everyone is raving about the all-new Yahoo! Mail beta.
--0-1335413932-1164266380=:20650
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

I have this code already, have a look at this few lines of code, which is already existing.
----------------------------------------------  
$query1 = "SELECT distinct link_id, url, title, description,  $fulltxt, size FROM ".$mysql_table_prefix."links WHERE link_id in ($inlist)";
  $result = mysql_query($query1);
  echo mysql_error();
---------------------------------------------
I have experience of past I would get number of responses, and php database mailing list had many members world wide, only single response, why?
----------------------------------------------
In previous code, posted, can you have a look in case tables have been joined properly to respond to query and give proper search results.


Chris <dmagick@gmail.com
>
wrote:
Asif Qureshi wrote:
> Here I narrow down the problem.

I meant narrow down the problem in your code.

Add

echo "mysql error? " . mysql_error() . "
";

after your mysql_query calls for example.

--
Postgresql & php tutorials
http://www.designmagick.com/




Everyone is raving about
--0-1335413932-1164266380=:20650--


--0-1490261907-1164266561=:97324
Content-Type: text/plain; charset=us-ascii

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--0-1490261907-1164266561=:97324--

Re: Re: Fwd: Re: search error

am 25.11.2006 03:47:39 von Chris Smith

> ----------------------------------------------
> $query1 = "SELECT distinct link_id, url, title, description, $fulltxt, size
> FROM ".$mysql_table_prefix."links WHERE link_id in ($inlist)";
> $result = mysql_query($query1);
> echo mysql_error();

and what does $fulltxt contain when you get the error?

I suspect you have a problem with the quotes in that string.

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php