try{ //your pdo query here } catch(PDOException $e) { echo json_encode(array('Error'=>$e->getMessage())); }