I'm at my wits end, perhaps after working non stop for 7 hrs. I'm trying to develop a simple search engine using Php and Mysql. I have borrowed my idea of doing this from a wonderful youtube tutorial by nick frosty. Unlike Nick, i'm not doing this the procedural way rather the PDO way. I know this kinda question has been asked here before (as they say nothing new under the sun) but personally cannot figure why my results are not showing. here is the code snippet

<!DOCTYPE HTML>
<html>
<form action="" method="get">
<input type="text" name="search" value="<?php echo $_GET['search'] ?>"/>
<input type="submit"  value="search">
</form>
results<hr />
<?php
include $_SERVER['DOCUMENT_ROOT'] . '/data.php';
    if(isset($_GET['search'])){
        $searchquery = $_GET['search'];

        $searchquery = explode(' ', $searchquery);
        $i=0;
        $query = "SELECT * FROM manuscript WHERE ";
        print_r($searchquery);
        foreach($searchquery as $term){
            $i++;
            if($i == 1){
                $query .= "title LIKE '%$term%' ";
            }
            else{
                $query .= "OR title LIKE '%$term%' ";
            }


        }

echo "$query <br>";

//connect

$con = dbConnect();

$query = $con->prepare($query);
$query->execute();
$query->setFetchMode(PDO::FETCH_ASSOC);

            while ($row = $sql->fetch()){
                $manuscript_id = $row ['manuscript_id'];

                $title = $row['title'];
                echo "$title yesu <br>";
            }
//
$con = null;
}
 ?>

   </html>

Hi can you replace $sql to $query in line 39

while ($row = $sql->fetch())

into

while ($row = $query->fetch())

PHP is an object-oriented langauge. Use it that way! See my tutorial post about that. It will make your life much simpler, with a little forethought and setup.

Thank you very much Palanivelu Rajagopal. I cannot believe i looked at this code a thousand times but could not see the annomaly.....