2014-06-28 35 views
-1

我有一個php應用程序與php後端,問題是其中一個PHP腳本在本地服務器上完美工作,而在線時它不會產生以下錯誤:只在遠程服務器託管php腳本的錯誤

Parse error: syntax error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/malblbic/public_html/webservice/profile.php on line 23

這是我的php代碼。

<?php 

/* 
Our "config.inc.php" file connects to database every time we include or require 
it within a php script. Since we want this script to add a new user to our db, 
we will be talking with our database, and therefore, 
let's require the connection to happen: 
*/ 
require("config.inc.php"); 


//initial query 
$username = $_POST['username']; 
    $query = "Select * FROM users; 

//execute query 
try { 
    $stmt = $db->prepare($query); 
    $result = $stmt->execute(); 
} 
catch (PDOException $ex) { 
    $response[‘success’] = 0; 
    $response["message"] = "Database Error!"; 
    die(json_encode($response)); 
} 

// Finally, we can retrieve all of the found rows into an array using fetchAll 
$rows = $stmt->fetchAll(); 


if ($rows) { 
    $response["success"] = 1; 
    $response["message"] = "User Available!"; 
    $response["posts"] = array(); 

    foreach ($rows as $row) { 
     $post    = array(); 

     $post["picture"] = $row["picture"]; 
     $post["username"] = $row["username"]; 

     $post["points"] = $row["points"]; 


     //update our repsonse JSON data 
     array_push($response["posts"], $post); 
    } 

    // echoing JSON response 
    echo json_encode($response); 


} else { 
    $response["success"] = 0; 
    $response["message"] = "No Users Available!"; 
    die(json_encode($response)); 
} 

?> 
+1

除了在智能/彎引號'[ '成功']'(這已經下文提到的,你」在'$ query ='中丟失''''選擇* FROM用戶;'注意語法突出顯示? - 向文件頂部添加錯誤報告 'error_reporting(E_ALL); ini_set('display_errors',1) ;' –

回答

1

更改反引號經常引用

$response[‘success’] = 0; 

$response['success'] = 0; 
+0

此外,我建議,當php報告特定行上的錯誤時,請仔細檢查該行。 @FuzzyTree在這裏發現了明顯的問題,如果你看第23行,你可能會注意到這個問題。 –