Page 1 of 1

PHP Search Page

Posted: Mon Sep 29, 2008 1:23 pm
by kslagdive
hi friends,
I am working on Search code where it finds inserted keyword across our pages.
i am facing problem when inserting search pages in the database. because when
page contains only text then it is executing. but when image on page it is not executing.
Please, anyone help me regarding this.
thanks,
kashinath lagdive

Re: PHP Search Page

Posted: Mon Sep 29, 2008 1:26 pm
by The_Anomaly
You might want to give us more info/code. The fact that something "doesn't execute" when you "insert it into a database," isn't nearly enough information.

Re: PHP Search Page

Posted: Mon Sep 29, 2008 1:47 pm
by kslagdive
thanks,
here i am searching specific keyword across no of file in dir.
code is for searching all contents of files and insert it into database so that we
retrieve information matching those page title and some content description on result page.
code is like this
------------------------------------------------------------------------
<?php
$con = mysql_connect("localhost","root","");

mysql_select_db("mydata");

$delimiter = '/';

if($con!=null)
{

function parseCodeTree($path) {

global $delimiter;

if ($dir = opendir($path)) {

while ($item = readdir($dir)) {


if (is_dir($path.$delimiter.$item) && $item != "." && $item != "..") {


parseCodeTree($path.$delimiter.$item);


} elseif ($item != "." && $item != "..") {



$scriptTitle = str_replace(".php", "", $item);
$scriptTitle = str_replace("_", " ", $scriptTitle);

echo '------->'.''.$scriptTitle;


$scriptContents = file_get_contents($path.$delimiter.$item);

echo $scriptContents;


// Insert the file information into database
$query = "INSERT INTO searchtab VALUES('000', '$scriptTitle' , '$scriptContents')";
$result = mysql_query($query);

echo '<br>here is result------->'.''.$result;
}
}
closedir($dir);
}
return 1;
}

parseCodeTree('myPHP');
}
else
{
echo 'not connected';
}
?>
-----------------------------------------------------------------------
now this code executing means successfully loading database properly when only text on our pages.
image containing page is not properly inserting. So, Please help me regarding this.

Re: PHP Search Page

Posted: Mon Sep 29, 2008 1:56 pm
by The_Anomaly
Try editing that post, adding indentation, and using the code tags. Will be much easier to understand.

Without giving myself the headache of trying to comprehend it, what I think of offhand may have to do with your lack of escaping. If only text works, perhaps the presence of the HTML img tags and the paths contained there in is not being escaped properly and screwing up your code.

In any case, you probably should still be escaping it anyway.

In addition, I'm almost certain that there's a better way of making a PHP Search Engine for your site. It's such a common problem, there must be a myriad solutions for it. Do some googling. In just 10 seconds, I already found one, although I'm sure there are many others.

Re: PHP Search Page

Posted: Mon Sep 29, 2008 2:21 pm
by kslagdive
thank you Mr. Thomas sir,
i am working on your search link.