<?php
  $servername = "localhost";
  $username = "user";
  $password = "pass";
  $dbname = "test";
  $tablename = "mapcoords";
  $conn = new mysqli($servername, $username, $password, $dbname);
  if ($conn->connect_error)
  {
    echo "Failure";
    die("Connection failed: " . $conn->connect_error);
  }
  echo "Connected successfully";
  $sql = "SELECT (lat, lng) FROM mapcoords";
  $result = $conn->query($sql);
    while($row = $result->fetch_assoc())
    {
      echo "ok";
    }
  $conn->close();
?>
Here is the code. So like I said, it can connect successfully, but the code won't successfully query. What's weird is that if I copy and paste the same code, which seems to be EXACTLY the same, it works. It makes no sense. I can't find a single difference between their code and my code besides the way they space things and the way I space things. Here is their code:
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 
$sql = "SELECT (lat, lng) FROM mapcoords";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo $row["lat"]. " " . $row["lng"] . "<br>";
    }
} else {
    echo "0 results";
}
$conn->close();
?>
 
    