Forum Moderators: coopster
Thanks in advance,
Scott
--begin code--
<?php
// Server specifications:
// PHP5
// MySQL 5.0.15-nt
// Apache2
// Windows 2000 Pro// Test Strings total non sensitive: TOTAL 7 results
$srch='JEHOVAH';//case sensitive: 4 results
//$srch='Jehovah';//case sensitive: 3 results
//$srch='jehovah';//case sensitive: 0 results
//$srch='Jehovah ';//(With trailing space) case sensitive: 0 results; non sensitive: 3 results;
// Test case selector
$case=1;// 0=case not sensitive; 1=case sensitive;
$link=mysql_connect(
'localhost',
'apache',
''
);
if(!$link)
{
die('Could not connect...' . mysql_error());
}
// Works with 'WHERE BINARY' as recommended by Brent Baisley (brent@landover.com) from MySQL List.
// Once passed, create a stored procedure for this.
if($case==1)
{
$result=mysql_query("
SELECT
bo.book,
b.chapter,
b.verse,
b.text
FROM
avkjv.books bo
LEFT JOIN
avkjv.bible b
ON
b.book=bo.number
WHERE BINARY
text
LIKE
'%$srch%';
");
}
else// Still case sensitive -- Need to figure out a way to select nonsensitively.
{
$result=mysql_query("
SELECT
bo.book,
b.chapter,
b.verse,
b.text
FROM
avkjv.books bo
LEFT JOIN
avkjv.bible b
ON
b.book=bo.number
WHERE
text
LIKE
'%$srch%';
");
}
// If database is down or query is screwed up, inform user in a nice way.
if(!$result)
{
?><p>Sorry, the database is currently down, please try again later.</p><?
}
// Need to figure out a way to show user that there are no recordsets.
//elseif {}
// Datas has been selected, let's populate using definition list. (Accessibility?)
else
{
// Prepare the definition list format for printf
$format='
<dl>
<dd>%s %s:%s</dd>
<dt>%s</dt>
</dl>';
while($row=mysql_fetch_array($result, MYSQL_NUM))
{
printf($format,$row[0],$row[1],$row[2],$row[3]);
}
// Free up memory!
mysql_free_result($result);
// Close db
mysql_close($link);
}
?>
Changed and now works. -- Check if I'm missing anything? (trying to optimize my server)
<?php
// Test Strings total non sensitive: TOTAL 7 results
$srch='JEHOVAH';//case sensitive: 4 results
//$srch='Jehovah';//case sensitive: 3 results
//$srch='jehovah';//case sensitive: 0 results
//$srch='Jehovah ';//(With trailing space) case sensitive: 0 results; non sensitive: 3 results;
// Test case selector
$case=1;// 0=case not sensitive; 1=case sensitive; (checkbox radio)
$link=mysql_connect(// Connects MySQL Database
'localhost',
'apache',
''
);
if(!$link)// Connection failure notification.
{
die('Could not connect...' . mysql_error());
}
// Works with 'WHERE BINARY' as recommended by Brent Baisley (brent@landover.com) from MySQL List.
// Once passed, create a stored procedure for this with '0' or '1' case selector.
if($case==1)
{
$result=mysql_query("
SELECT
bo.book,
b.chapter,
b.verse,
b.text
FROM
avkjv.books bo
LEFT JOIN
avkjv.bible b
ON
b.book=bo.number
WHERE
text
LIKE
'%$srch%';
");
}
elseif($case=0)// Still case sensitive -- Need to figure out a way to select nonsensitively.
{
$result=mysql_query("
SELECT
bo.book,
b.chapter,
b.verse,
b.text
FROM
avkjv.books bo
LEFT JOIN
avkjv.bible b
ON
b.book=bo.number
WHERE
UPPER(text)
LIKE
'%" . strtoupper( $srch ) . "%'
");
}
// If database is down or query is screwed up, inform user in a nice way.
if(!$result)
{
?><p>Sorry, the database is currently down, please try again later.</p><?
}
// Need to figure out a way to show user that there are no recordsets.
// elseif {}
// Datas has been selected, let's populate using definition list. (Accessibility?)
else
{
// Prepare the definition list format for printf
$format='
<dl>
<dd>%s %s:%s</dd>
<dt>%s</dt>
</dl>';
while($row=mysql_fetch_array($result, MYSQL_NUM))
{
printf($format,$row[0],$row[1],$row[2],$row[3]);
}
// Free up memory!
mysql_free_result($result);
// Close db
mysql_close($link);
}
?>
WHERE text LIKE '%$srch%'; "); // (as you have it.)
... and the case-sensitive search should be...
WHERE binary text LIKE '%$srch%'; ");
Another point, regarding the join, do you have an index defined on bible.book?