PHP:
// explode
$msg = "";
$pattern ="";
$boolpattern = "";
$keywords = "";
$suche = htmlentities($_POST['suchtxt']);
$words = explode(" ", $suche);
foreach($words as $word) {
$word = trim($word);
if($word=="")
continue;
// * nur am ende erlaubt
$pos = strpos($word, "*");
while($pos!==FALSE && $pos!=strlen($word)-1) {
$word = substr($word, 0, $pos) .
substr($word, $pos+1, strlen($word)-$pos-1);
$pos = strpos($word, "*"); }
// zu kurze wörter ignorieren
if(strlen($word) >= 4) {
$boolpattern .= "+$word ";
$pattern .= str_replace('*', '', $word) . " ";
$keywords .= "$word "; }
elseif(strlen($word)>0)
$msg .= "'$word' hat weniger als 3 Buchstaben und wird ignoriert.<br> ";
}
if($msg!="")
echo $msg;
if($pattern=="")
return;
// abfrage db
$sqla = "SELECT * MATCH(txt) ".
"AGAINST('$boolpattern' IN BOOLEAN MODE) AS mtch1, ".
"MATCH(txt) ".
"AGAINST('$pattern') AS mtch2 ".
"FROM $tbdat HAVING mtch1>0 ORDER BY mtch2";
$sqlb = mysql_query($sqla);
while ($sqlc = mysql_fetch_array($sqlb)) {
echo $sqlc['ID']."<br>";
}
Bekomme immer ein
mysql_fetch_array(): supplied argument is not a valid MySQL result resource
Sieht jemand wadd ich falsch mach?
Grüsse
campari