function getCityAndStateNames($mysqli, $filename) { $i = 0; $handle = fopen($filename, "r"); if ($handle) { while (($line = fgets($handle)) !== false) { // process the line read. $temp = explode(',', $line); if (getGeoPosition($temp[0], $temp[1], $mysqli, 0) == false) { break; } // break; $i++; } fclose($handle); } else { echo "on open file"; // error opening the file. } echo "Read" . $i . " places"; }
} else { echo json_encode(array("status" => "OK", "id" => $conn->insert_id)); $conn->close(); exit; } } if ($_POST['nombre'] && $_POST['mensaje']) { $conn = getConn(); if ($_POST['id']) { if (!$conn->query(sprintf("update messages set message = '%s', person_name = '%s', help_amount = help_amount + %s where id = %s", $_POST['mensaje'], $_POST['nombre'], $_POST['extra_kg'], $_POST['id']))) { echo $conn->error; $conn->close(); exit; } } else { if (!$conn->query(sprintf("insert into messages (message,person_name,location,creation_date,help_amount,province) values ('%s','%s','%s','%s',%s,'%s')", $_POST['mensaje'], $_POST['nombre'], getLocation(), date("Y-m-d H:i:s"), $_POST['extra_kg'], getGeoPosition(getLocation())))) { echo $conn->error; $conn->close(); exit; } } header('Location: messages.php'); } function getKgObtained() { $conn = getConn(); $res = $conn->query("select sum(help_amount) as cuenta from messages"); if (!$res) { return 0; } $row = $res->fetch_object();