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

<form action="" method="get">
<input type="text" name="search" value="<?php echo $_GET['search'] ?>"/>
<input type="submit"  value="search">
results<hr />
include $_SERVER['DOCUMENT_ROOT'] . '/data.php';
        $searchquery = $_GET['search'];

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


echo "$query <br>";


$con = dbConnect();

$query = $con->prepare($query);

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

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


Recommended Answers

All 4 Replies

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

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


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.....

thanks Amaina

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.