<?php
$servername = "localhost";
$username = "root";
$password = "";
$id=$_REQUEST["id"];
$sql = "SELECT password from usuarios where id=".$id;
try
{
$conn = new PDO("mysql:host=$servername;dbname=prueba", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmn = $conn->prepare($sql);
$stmn->execute();
$data = $stmn->fetchAll(PDO::FETCH_ASSOC);
$myJSON = json_encode($data,128);
echo $myJSON;
}
catch(PDOException $e)
{
//conexion fallida - retorna 0
$myJSON = json_encode(0,128);
echo $myJSON;
}