Question

line 19 is $Image_path = $row->Image_path;

Hey guys i have NO idea why im getting this error... since it's the first time I'm calling this variable and also the $row->Image_path is an actual feild in the table. Any ideas? beats me

here's the code

<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');
$search_output = "";
if(isset($_POST['searchquery']) && $_POST['searchquery'] != ""){
    $searchquery = preg_replace('#[^a-z 0-9?!]#i', '', $_POST['searchquery']);
    if($_POST['filter1'] == "Companies"){
        $sqlCommand = "SELECT Company_ID, Company_Name, Image_path AS company FROM Company WHERE Company_Name LIKE '%$searchquery%'";
    }
    include_once("database_connect.php");
        $query = mysqli_query($connection, $sqlCommand) or die(mysql_error());
    $count = mysqli_num_rows($query);
    if($count >= 1){
        $search_output .= "<hr />$count results for <strong>$searchquery</strong><hr />$sqlCommand<hr />";
        while($row = mysqli_fetch_array($query)){
                $id = $row->Company_ID;
            $Company_name = $row->Company_Name;
             $Image_path = $row->Image_path;
            $search_output .= "Item ID: $ $Image_path.$Company_name<br />";
                } // close while
    } else {
        $search_output = "<hr />0 results for <strong>$searchquery</strong><hr />$sqlCommand";
    }
}
?>
Was it helpful?

Solution

You need to change mysqli_fetch_array to mysqli_fetch_object.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top