2016-11-23 13 views
1

私はMySQLデータベースをPHP経由でiPhoneアプリに接続しようとしています。私はこのチュートリアルに従っていますhttp://codewithchris.com/iphone-app-connect-to-mysql-database/私のPHPファイルは何も返されないのですか?

このようなことは初めてです。私はいくつかの重要な情報を残しておきたいのですが、残念です。ここで

はここでここで

Here's Bluehost

私の問題お申し込み

Here's the plist in Xcode

Xcodeでplistのだ、私はお申し込み

<?php 

// Create connection 
$con=mysqli_connect("localhost","gaethrco_travis","Energy=mc^2","gaethrco_data"); 

// Check connection 
if (mysqli_connect_errno()) 
{ 
    echo "Failed to connect to MySQL: " . mysqli_connect_error(); 
} 

// This SQL statement selects ALL from the table 'Locations' 
$sql = "SELECT * FROM Locations"; 

// Check if there are results 
if ($result = mysqli_query($con, $sql)) 
{ 
    // If so, then create a results array and a temporary one 
    // to hold the data 
    $resultArray = array(); 
    $tempArray = array(); 

    // Loop through each row in the result set 
    while($row = $result->fetch_object()) 
    { 
     // Add each row into our results array 
     $tempArray = $row; 
     array_push($resultArray, $tempArray); 
    } 

    // Finally, encode the array to JSON and output the results 
    echo json_encode($resultArray); 
} 

// Close connections 
mysqli_close($con); 
?> 

上のデータベースにアップロードPHPファイルですは私が自分のウェブサイトに行くと、gaethr.com/service.php 何も起こりません。チュートリアルによると、これは私はいくつかの重要な情報を残している場合は、私に教えてください

This is what should happen

が起こるはずです。

+0

をレコードセット

if ($result = mysqli_query($con, $sql)) { .... } else { echo "No results"; } 

を検証私はこれらのタグを削除しています。 – Alexander

+0

クエリが成功したかどうかをチェックする必要があります。接続は正常ですが、クエリが失敗しました(たとえば、 'Locations'テーブルは存在しません)。 {...} else {echo mysqli_error($ con); } '*または何か* – HPierce

答えて

0

まず検証$詐欺

if (!$con) { 
    die("Connection error: " . mysqli_connect_errno()); 
} 

次にこの質問は、iOSの、スウィフト3、またはXcodeの8とは何の関係もありません...次に

if(!empty($result) { 
    while ($row = mysqli_fetch_array($result)) { 
... 
+0

彼らはすでにそれをやっています。あなたはちょっと違ったやり方をしています。 –

関連する問題