I have 2 questions from this query.
$query = mysql_query($con, "SELECT id, ".calcDistance($mLat, $mLng, ."lat"., ."lng".)." as distnc FROM users WHERE fName LIKE '%".$search."%' OR lName LIKE '%".$search."%' ORDER BY distnc");
Now before I go on with the questions let me explain my variables
and functions
.
calcDistance()
is a function that returns the distance from 2 latitudes and longitude, actually latitude and longitude of the logged in user and another user. And the parameters passed are the logged in user latitude
, logged in user longitude
, second user latitude
and second user longitude
.
$mLat
is a variable for the logged in user latitude
$mLng
is a variable for the logged in user longitude
lat
and lng
are column names in the MySQL database table called users
.
Now my main aim is to show searched result ordering the result by the nearest user with the search word. Which is the reason I am using the calcDistance()
function in the query.
FIRST QUESTION
When I run this query, I get a Parse error: syntax error, unexpected '.'
. I don't know why I am getting this error.
SECOND QUESTION
I tried passing numbers directly as the parameters so as to stop the error I get from the 1st question. But I still get another error Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given
.
My aim is to order a user search according to the nearest user. Using the calcDistance()
returns the distance between the logged in user and another user like I said.
The lat
and lng
columns are columns where each user latitude and longitude are saved