[英]SyntaxError: Unexpected token < in JSON at position 0 php
hey there i have an issue with my php coding i think, i am getting SyntaxError: Unexpected token < in JSON at position 0 嘿,我认为我的php编码有问题,我正在收到SyntaxError:意外的标记<在JSON中的位置0
during the success part of a jquery ajax form post. 在jquery ajax表单发布的成功部分中。 the php code is sending me back 的PHP代码送我回来
<?
?>{"Status":"Login Success"}
the php code is as follows 的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;
?>
i have no idea why im getting the response it gives. 我不知道为什么即时通讯得到它给出的响应。 please help 请帮忙
Since this file uses <?php
and not just <?
由于此文件使用<?php
而不仅仅是<?
as opening tags, the output comes from another file. 作为开始标签,输出来自另一个文件。 You could either find that file and remove those 5 lines, or enable short tags (see How to enable PHP short tags? ). 您可以找到该文件并删除这5行,或者启用短标签(请参阅如何启用PHP短标签? )。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.