The following is my php code with SQL.
$con=mysqli_connect("localhost","root","","ananas");
if (mysqli_connect_errno()) {
echo json_encode(mysqli_connect_errno());
}
$sql = "SELECT venues.*, (6371*acos(cos(radians(".$curr_lat."))*cos(radians(venues.lat))*cos(radians(venues.longi)-radians(".$curr_longi."))+sin(radians(".$curr_lat."))*sin(radians(venues.lat)))) AS radius
FROM venues
HAVING radius < ".$radius ;
$result = mysqli_query($con,$sql);
if (!$result) {
die("Error running $sql: " . mysql_error());
}
I ve verified all the database, table names and column names I wanna extract are working fine. Even same code was working fine before I reinstalled xampp and reset my phpmyadmin with DB.
But now even with older setting, i.e. after restoring the same database, tables, username & password as before I get an error. It shows error when I try calling it from JS file using xmlhttprequest object.
The following is my JS function for calling the PHP file through xmlhttp
function loadXMLDoc(city)
{
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
myData= eval("(" + xmlhttp.responseText + ")");
console.log(myData);
$('#header_bottom_wrapper .nav span').html(city);
mapMarkers(myData);
map.fitBounds(circle.getBounds());
loadPlaces();
getVenues();
}
else{
alert(status+", "+exception);
}
}
xmlhttp.open("GET","./content/sessionVariableChange.php?city="+city+"&curr_lat="+curr_lat+"&curr_longi="+curr_longi+"&radius="+radius+"&capacity="+capacity,true);
xmlhttp.send();
}
sessionVariableChange.php is the name of php file where I access my database.
When I try to run the file, I get the following error in my console. **Uncaught SyntaxError: Unexpected token ) **
Any help would be helpful. Thanks in advance.