From: kiran_jack at rediffmail dot com
Operating system: apache
PHP version: 4.3.1
PHP Bug Type: Strings related
Bug description: problem withs strings

Description:
------------
I have a problem with a query. I'd like to make a search in a table
inserting 2 or more words in the input form, using the OR. Everything
works fine with 1 word but with more I obtain result only for the LAST
inserted one
Please reply me soon,
Jack



Reproduce code:
---------------
<?php
require 'db_connect1.php';
if ($search) // perform search only if a string was entered.
{

$words = explode (" ", $search);
$num = COUNT ($words);
WHILE ($n<$num) {
$queryWhereArray = "(description like %".$words[$n]."% || keywords like
%".$words[$n]."% || cost like %".$words[$n]."% )";
}
$queryWhere = join(" or ",$queryWhereArray);
$query = "select count(id) as k, *
from search
where $queryWhere group by k
order by id desc";





$result = mysql_query($query);
$num_rows = mysql_num_rows($result);

if (!($num_rows))
{
echo "Sorry - no matches were found. Please <a
href=\"search1.html\">go back</a> and try some different search terms.";
}

else {
echo "<font face=verdana,sans-serif size=-1>";
echo "Search Results:";
while ($r = mysql_fetch_array($result))
{ // Begin while
echo "<br>";
$id1=$r["id"];
$link1= $r["link"];
$meta= $r["description"];
$keywords1= $r["keywords"];
$figure=$r["picture"];
$price=$r["cost"];

echo "<table border=0 cellpadding=0 cellspacing=0>";
echo "<tr>";
echo "<td width=50>";
echo "$id1";
echo "</td>";
echo "<td width=500>";
echo "<a href='$link1'>";
echo "$meta";
echo "</a>";
echo "<br>";
echo "$keywords1";
echo "</td>";
echo "<td>";
echo "Rs";
echo "$price";
echo "/-";
echo "</td>";
echo "</tr>";

echo "<br>";
echo "<br>";

} // end while
echo "</table>";
echo "</font>";
}
}
else
echo "You did not enter anything to search for. Please <a
href=\"search1.html\">go back</a> and enter a search word.";
?>

Expected result:
----------------
i want to search the entire string


--
Edit bug report at [url]http://bugs.php.net/?id=26055&edit=1[/url]
--
Try a CVS snapshot (php4): [url]http://bugs.php.net/fix.php?id=26055&r=trysnapshot4[/url]
Try a CVS snapshot (php5): [url]http://bugs.php.net/fix.php?id=26055&r=trysnapshot5[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=26055&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=26055&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=26055&r=needtrace[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=26055&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=26055&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=26055&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=26055&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=26055&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=26055&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=26055&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=26055&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=26055&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=26055&r=gnused[/url]
Floating point limitations: [url]http://bugs.php.net/fix.php?id=26055&r=float[/url]