I have no idea why this isn't working but maybe because I am guessing?
What I am trying to accomplish...
Ultimately what I would like is to be able to submit MS Word documents, which get uploaded(uploading works), then be able to search within those Word documents. It seems that Word formatted documents are probably binary, so I can accept this, but if there is a way to search MS Docs, please let me know!!
Anyways, Plan B.
Plan B has the Word documents saved as text files. Then uploaded. Now I want to be able to search within these text documents.
The location of the files are held in the database, which works fine...
Now I want to search within the text documents via a search form for keywords
Here is what I came up with.. I winged it..
<?
include "variables.php";
$delimiter = ",";
$connection = @mysql_connect($databaseserver, $databaseuser, $databasepass) or die ("could not connect to database");
$db = @mysql_select_db($databasename, $connection) or die("Could not select database");
$sql = "SELECT id, FirstName, LastName, ResumeUp FROM $canidatetable";
$result = mysql_query($sql, $connection) or die("Couldn't execute query");
while ($row = mysql_fetch_array($result))
{
$id = $row['id'];
$FirstName = $row['FirstName'];
$LastName = $row['LastName'];
$filename = $row['ResumeUp'];
$fd = fopen("/home/sites/madden.williamsen.net/web/recruiter/resumes/","rb");
$contents = fread($fd, filesize($filename));
$keywords = explode( $delimiter, $words );
for ($i=0; $i < count($keywords); $i++) {
$kw = $keywords[$i];
if( eregi($kw, $contents) ) {
echo "The Words <b>$kw</b> has been found in the resume of
<ol><li>$LastName, $FirstName <a href=\"http://madden.williamsen.net/recruiter/resumes/$filename\">Resume</a></li></ol>";
}
else {
echo "The keyword <b>$kw</b> was not found in the resume
$filename<br>";
}
}
fclose($fd);
}
?>