FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Bug Reports » Bug in search.php (PHP problem, solution inside)
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Bug in search.php (PHP problem, solution inside) [message #22202] Thu, 20 January 2005 09:41 Go to previous message
devnull is currently offline  devnull   Germany
Messages: 16
Registered: September 2004
Karma:
Junior Member
Some people noticed SQL errors when searching for a number-only string. I traced the bug back to the function "text_to_worda" in search.php; it returns an empty array when $text contains only numbers, effectively leading to a SQL error in line 445, because $qr is empty.

The reason for that is the PHP function str_word_count in line 339. It handles numbers just like whitespace.
http://www.php.net/manual/en/function.str-word-count.php

To fix this, I replaced str_word_count with preg_replace. So far, the search works fine. However, a search containing a number won't return any matches (I guess they are not indexed). But at least the error message is gone.

Original line 339:
$t1 = array_unique(str_word_count(strip_tags(strtolower($text)), 1));
Replaced with:
$t1 = array_unique(preg_split("/\s+/", strip_tags(strtolower($text))));

I'm using FudForum 2.6.6 on Apache/2.0.46 with PHP 4.3.2 (Zend 1.3.0) using MySQL 11.18 Distrib 3.23.58.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: E-mail confirmation problem
Next Topic: BROKEN lock/unlock files in 2.6.6
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 20:31:49 GMT 2024

Total time taken to generate the page: 0.04671 seconds