Advertisement
Guest User

Untitled

a guest
Jul 16th, 2012
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getBeaches() {
  2.  
  3.     $sql="SELECT * FROM `beaches` WHERE city=:city";
  4.  
  5.     try {
  6.         $db         = getConnection();
  7.         $stmt       = $db->prepare($sql);
  8.  
  9.             $stmt->bindValue(':city',   'seattle'); //should bind seattle
  10.             $stmt->execute();
  11.         $beaches    = $stmt->fetchObject();
  12.         $db         = null;
  13.  
  14.         echo '{"map": ' . stripslashes(json_encode($beaches)) . '}';
  15.     } catch(PDOException $e) {
  16.         echo '{"error":{"text":'. $e->getMessage() .'}}';
  17.     }
  18.  
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement