Advertisement
Guest User

julosWtf

a guest
Sep 30th, 2014
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.72 KB | None | 0 0
  1. <?php
  2.  
  3.     include '../functions.php';
  4.     session_start();
  5.     if(isset($_POST['id'])){
  6.        
  7.         $db = connectToDb('myDb');
  8.         $db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
  9.         $db->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
  10.         $id = $_POST['id'];
  11.         $getGeo = $db->prepare("SELECT Y(geo_position) AS y FROM geo WHERE geo_id = :id");
  12.         $getGeo->execute(['id'=>$id]);
  13.         if (!$getGeo->rowCount()) {
  14.             // no results for given $id, handle error
  15.             echo "ERROR ROWCOUNT";
  16.         }
  17.         $y = $getGeo->fetchColumn(0);
  18.         $getGeo->closeCursor();
  19.         echo json_encode($y);
  20.     }else{
  21.         echo "ERREUR ID NOT SET";
  22.     }
  23.  
  24. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement