I am trying to solve something out. this time I am using mysqli and not PDO.
The problem: I am getting an error saying: "Notice: Trying to get property of non-object in ..." I only get that problem when I put the LIKE or " = " statement in the sql query, when I remove it, it is good.
What I am trying to do: Basically, I am saying if the option in the dropdown is selected, then get some info about the agencies in that specific city location only.
Here is my code:
if(isset($_POST["submit"])){
$elpost = $_POST["cityName"];
$sql = "SELECT office_name, office_location, office_phone FROM `easyt_findagents_agents WHERE office_city='$elpost";
$result = $db->query($sql);
//Display states list
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo $row['office_name'];
}
} else {
echo "0 results";
}
}
any thoughts on how to fix that? I've searched a lot but didn't find anything why this is happening.
Thanks in advance for everybody.