function get_all_posts() { $link = open_database_connection(); $sql = 'SELECT * FROM posts'; $result = mysqli_query($link, $sql); $posts = array(); while ($row = mysqli_fetch_array($result, MYSQL_ASSOC)) { $posts[] = $row; } close_db_connection($link); return $posts; }
function newsletter_remove($email) { try { $conn = open_db_connection(); $sql = "SELECT email FROM newsletter WHERE email = '" . $email . "';"; $result = $conn->query($sql); if ($result->num_rows == 0) { $msg = "L'email non risulta nella lista di invio."; } else { $sql = "DELETE FROM newsletter WHERE email = '" . $email . "';"; $conn->exec($sql); $msg = "Email rimossa dalla lista di invio."; } } catch (PDOException $e) { $msg = "Errore di sistema. Contattare info@ilterzospazio.org"; } close_db_connection($conn); return $msg; }
<?php include "../config.php"; include "../functions.php"; include "../private_functions.php"; if (isset($_GET['keyword']) && $_GET['coorx'] && $_GET['coory'] && $_GET['range']) { $dbh = db_connect($MY_HOST, $MY_DB_PORT, $MY_DB, $DB_USER, $DB_PW); $num = 10; if (isset($_GET['count']) && is_numeric($_GET['count'])) { $num = $_GET['count']; } $res = search_range($dbh, $_GET['keyword'], $_GET['coorx'], $_GET['coory'], $_GET['range'], $num); close_db_connection($dbh); echo json_encode($res); } else { echo json_encode(array("status" => -1)); }
// geocode try { $location_XML = yahoo_geo($_REQUEST['location']); $location = $location_XML['Latitude'] . "," . $location_XML['Longitude']; $location_latitude = $location_XML['Latitude']; $location_longitude = $location_XML['Longitude']; // get event number $event_index = $_POST['event_index']; if ($event_index > 0) { $conn = get_db_connection($db_user, $db_passwd, $db_name); $event_label = $event_index; $latitudes[$event_index] = $location_latitude; $longitudes[$event_index] = $location_longitude; $sql_result = save_vote($location_latitude, $location_longitude, $event_label); // $db_status_close = close_db_connection($conn); } else { $event_label = ""; } // $map_click_X = $_POST['map_x']; $map_click_Y = $_POST['map_y']; } catch (exception $e) { $location_latitude = 0; $location_longitude = 0; // or display default entry page $location = ""; $place_name = ""; $event_index = 0; $event_label = ""; }