Advertisement
Guest User

Untitled

a guest
Aug 1st, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. <?php
  2. $username="usrname";
  3. $password="passwd";
  4. $database="a1xxxxx_mydb";
  5. $host="mysqlxx.000webhost.com";
  6. mysql_connect($host,$username,$password);
  7. @mysql_select_db($database) or die( "Unable to select database");
  8. if (isset($_GET["userLatitude"]) && isset($_GET["userLongitude"])) {
  9.  
  10. $userLatitude=$_GET['userLatitude'];
  11. $userLongitude=$_GET['userLongitude'];
  12. $result = mysql_query("SELECT locationName, ( 6371 * acos( cos( radians(floatval( $userLatitude) )) * cos( radians( locationLatitude ) ) * cos( radians( locationLongitude ) - radians( floatval($userLatitude)) ) + sin( radians(floatval($userLongitude)) ) * sin( radians( locationLatitude) ) ) ) AS distance
  13. FROM Location HAVING distance < 2 ORDER BY distance LIMIT 0 ,20") or die(mysql_error());
  14. echo $result;
  15.  
  16. // check for empty result
  17. if (mysql_num_rows($result) > 0) {
  18. // looping through all results
  19. // products node
  20. $response["Location"] = array();
  21.  
  22. while ($row = mysql_fetch_array($result)) {
  23. // temp user array
  24. $product = array();
  25. $product["locationName"] = $row["locationName"];
  26. $product["locationInfo"] = $row["locationInfo"];
  27. $product["locationLatitude"] = $row["locationLatitude"];
  28. $product["locationLongitude"] = $row["locationLongitude"];
  29. $product["locationPic"] = $row["locationPic"];
  30. $product["city"] = $row["city"];
  31.  
  32.  
  33.  
  34. // push single product into final response array
  35. array_push($response["Location"], $product);
  36. }
  37. // success
  38. $response["success"] = 1;
  39.  
  40. // echoing JSON response
  41. echo json_encode($response);
  42. } else {
  43. // no products found
  44. $response["success"] = 0;
  45. $response["message"] = "No products found";
  46.  
  47. // echo no users JSON
  48. echo json_encode($response);
  49. }
  50. }
  51. else {
  52. // required field is missing
  53. $response["success"] = 0;
  54. $response["message"] = "Required field(s) is missing";
  55.  
  56. // echoing JSON response
  57. echo json_encode($response);
  58. }
  59. mysql_close();
  60. ?>
  61.  
  62. mysql_upgrade -u root -p
  63.  
  64. service mysqld restart
  65.  
  66. my $rv = $sth_indexq->fetchall_arrayref;
  67.  
  68. DBD::mysql::st execute failed: Column count of mysql.proc is wrong. Expected 20, found 16. Created with MySQL 50520, now running 50528. Please use mysql_upgrade to fix this error. at
  69. ...
  70.  
  71. my $rv = $sth_indexq->fetchrow_arrayref;
  72.  
  73. mysql_upgrade --force -uroot -p
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement