我有一个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));
}
?>
除了在智能/弯引号'[ '成功']'(这已经下文提到的,你”在'$ query ='中丢失''''选择* FROM用户;'注意语法突出显示? - 向文件顶部添加错误报告 'error_reporting(E_ALL); ini_set('display_errors',1) ;' –