2017-05-30 4 views
0

自分のDBからデータを取得し、それを配列に挿入してアンドロイドアプリケーションに渡します。取り込むデータ:fetch()を使って値を取得するPHP

コテージはすべて、エコツーリズムの厳しい規範に従ってインラインで組み立てられており、森林被覆の元の性格と頑丈さを保ちます。車が止まると、丘と松の木で覆われた穏やかな丘の斜面に身を置くことができます。 Shimlaの最高級リゾートShoghiのAamodへようこそ。 Aamod Shoghiの秘密は、私たちのベーカリーです。焼きたてのおいしさの香りは、起きるごとにあなたを誘惑します。家に持ち帰るためにいくつかの詰め合わせを梱包するよう頼んだら、驚かれることはありません。私たちはシムラーのレストランで最高のパン屋であると主張しています。 アモドでの一日は、決して行動がない。あなたの窓を早朝に開き、壮大な景色と新鮮な空気をお楽しみください。そして、これであなたの一日が驚きに満ちた始まりです。広々とした芝生でチームの朝食をしたり、多数の施設の助けを借りて興味深いチームビルディングゲームをしたりしてください。広々とした会議室でビジネスリトリートを楽しむことができます。あなたのチームはチームの活動に忙しい中で、専門的に維持されているチッピングとグリーンのゴルフで、ゴルフの試合で次のリーダーシップの後退を計画することができます!

しかし、スクリプトは毎回クラッシュします。

$resort_name = $_POST['resort_name']; 

$sql = "SELECT resort_desc from resorts where resort_name = :resort_name"; 
$stmt = $conn->prepare($sql); 
$stmt->bindParam(':resort_name', $resort_name, PDO::PARAM_STR); 
$stmt->execute(); 
if($stmt->rowCount()){ 
    $response["resort_desc"] = array(); 
    $response["resort_desc"][0] = $stmt->fetch(); 
    $response["success"] = 1; 
} else { 
    $response["success"] = 0; 
} 

結果のサイズが大きすぎますか?もしそうなら、私はこのデータをどのように入手できますか?

のvar_dump( '応答') `

array(1) { 
    array(2) { 
    ["resort_desc"]=> 
    string(1135) "The cottages are all pre-fabricated structures in-line with the strict norms of Ecotourism so as to retain the original character and ruggedness of the forest cover. As the car stops, you�ll find yourself on a gentle hill slope, under a thick cover of oak and pine trees. Welcome to Aamod at Shoghi, the finest resort of Shimla. Another of our best kept secrets at Aamod Shoghi is our bakery. The aroma of freshly baked goodies will entice you every waking hour. We won�t be surprised if you ask us to pack a few assortments to carry back home. We claim to be the best bakers in all of Shimla restaurants. A day at Aamod is never without action. Open your windows early morning for a majestic view and fresh air. And with this begins your day full of surprises. Have team breakfast in our sprawling lawns or play interesting team building games with the help of our multitude of facilities. You can have Business retreats in our spacious conference rooms. While your team is busy at team building activities you can plan your next leadership retreat over a game of golf on our professionally maintained chipping and putting greens!" 

    string(1135) "The cottages are all pre-fabricated structures in-line with the strict norms of Ecotourism so as to retain the original character and ruggedness of the forest cover. As the car stops, you�ll find yourself on a gentle hill slope, under a thick cover of oak and pine trees. Welcome to Aamod at Shoghi, the finest resort of Shimla. Another of our best kept secrets at Aamod Shoghi is our bakery. The aroma of freshly baked goodies will entice you every waking hour. We won�t be surprised if you ask us to pack a few assortments to carry back home. We claim to be the best bakers in all of Shimla restaurants. A day at Aamod is never without action. Open your windows early morning for a majestic view and fresh air. And with this begins your day full of surprises. Have team breakfast in our sprawling lawns or play interesting team building games with the help of our multitude of facilities. You can have Business retreats in our spacious conference rooms. While your team is busy at team building activities you can plan your next leadership retreat over a game of golf on our professionally maintained chipping and putting greens!" 
    } 
} 
["success"]=> 
int(1) 
} 
+0

クラッシュはどういう意味ですか?エラーが表示されるかどうか? – Anton

+0

戻ってきたデータはありません。私は郵便配達所を調べた。 var_dump($ _ POST)を使用すると、データは渡されたがエコーバックはないことがわかります。 @Anton –

+0

このスクリプトでは、データをAndroidアプリにどのように渡していますか? – CoderSam

答えて

0

あなたが$stmt->fetch()を使用する場合、それは、結果セットではなく、個々の値を返します。 何かのようにする

$data = $stmt->fetch(); 
$response["resort_desc"][0] = $data["resort_desc"]; 
+0

に投稿されました。変更しないことを試しました:( –

+0

これはおそらく不要なので[0]を削除できますか? '$ response [" resort_desc "] = array ); '。 –

+0

完了:@Nelel –

関連する問題