SyntaxError:意外标记<;在JSON中的位置0 php
嘿,我有一个问题与我的php编码我想,我得到了 SyntaxError:JSON中位置0处出现意外标记< 在jqueryajax表单发布的成功部分。php代码正在将我发回SyntaxError:意外标记<;在JSON中的位置0 php,php,json,Php,Json,嘿,我有一个问题与我的php编码我想,我得到了 SyntaxError:JSON中位置0处出现意外标记
<?
?>{"Status":"Login Success"}
{“状态”:“登录成功”}
php代码如下所示
<?php
header('Content-type: application/json');
//Load DB Connection
require('Global.php');
require('dbConnect.php');
require('Studio7WebClass.php');
//Get form data
$username = $_POST['user'];
$password = $_POST['pass'];
$returnJSON = array('Status'=>'');
$finalJSON = "";
$Studio7Current = new Studio7Web;
$Studio7Current->set_username($username);
try{
$statement = $conn->prepare("select * from Users where (Username = :name OR EmailAddress = :name)");
$statement->execute(array(':name' => $username));
$row = $statement->fetch();
if (is_null($row)){
$returnJSON['Status'] = "User Not Found";
$finalJSON = json_encode($returnJSON);
}
else{
//Now check if the password matches the one the user entered.
if($row['password'] == $password){
//Passwords match
$returnJSON['Status'] = "Login Success";
$finalJSON = json_encode($returnJSON);
}else{
$returnJSON['Status'] = "Password Error";
$finalJSON = json_encode($returnJSON);
}
}
}catch(PDOException $e){
$returnJSON['Status'] = $e->getMessage();
$finalJSON = json_encode($returnJSON);
file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND);
}
echo $finalJSON;
?>
我不知道为什么我会得到它的回应。请提供帮助,因为此文件使用
如果LOL,请详细说明我是一个相当新的php编码器;)<代码>我将标题设置为json,它仍然会响应您需要的所有文件是否都有代码?现在大多数PHP版本默认启用短标记-这不是问题:)