make query ->execute query $con=mysqli_connect("csmysql.snc.edu","mohrjv","LostDogs2019","LostDogs2019"); //Query to insert a dog if($field == "email") // double quote for string $query = "SELECT * FROM dogs WHERE email = ".'"'.$field_value.'"'; else // single quote for number $query = "SELECT * FROM dogs WHERE missing = "."'".$field_value."' AND breed = ".'"'.$breed.'"'; $result = mysqli_query($con,$query); // get rows from db fwrite($myfile, mysqli_num_rows($result)." num rows\n"); // test // now do something with result... // array with int index - for loop from link // https://www.php.net/manual/en/mysqli-result.fetch-assoc.php for ($set = array (); $row = $result->fetch_assoc(); $set[] = $row); echo json_encode($set); // send it back to Java as JSON fwrite($myfile, var_export(json_encode($set), true)); // test fclose($myfile); // test ?>