I want to display the nearest location around me by the following code
<?php
$lat = "27.7350758";
$long = "85.3102946";
$result = $conn->query( 'SELECT * , (3956 * 2 * ASIN(SQRT( POWER(SIN(( $lat - college_lat) * pi()/180 / 2), 2) +COS( $lat * pi()/180) * COS(college_lat * pi()/180) * POWER(SIN(( $long - college_lon) * pi()/180 / 2), 2) ))) as distance from colleges having distance <= 10 order by distance' );
if ( $result->num_rows>0 ) {
// output data of each row
while( $row = $result->fetch_assoc() ) {
echo '<div class="category"><div class="cover" style="background-image: url(img/animation.jpg);"><div>'; ?>
<td><?php echo $row[ "college_name" ]; ?></td>
<?php
echo '</div></div><span class="counter ">Courses : <span>' . $row[ "college_courses" ] . '</span></span>';
echo '<span class="counter "> Distance : <span>' . $row[ "college_address" ] . '</span></span>';
echo '<span class="near-you"> <p>'. substr( $row[ "college_desc" ], 0 , 100) . '</p> </span></div>'; ?>
<a href="single.php?college_id=<?php echo $row['college_id'];?>"> Read More... </a>
<?php
}
} else {
echo "Colleges Not Found Please add";
}
?>
When i run this code following error will display
Notice: Trying to get property of non-object in C:\xampp\htdocs\college\index.php on line 56 Colleges Not Found Please add
If I remove $lat and $long, then keep the value on query it works. What is my mistake please suggest me. Thank you