我的程序没有在jsonlint验证器中验证

时间:2015-02-02 16:19:49

标签: php

 <?php$host="localhost";
$db="profile";
$user="root";
$pass="";
$connection=mysql_connect($host,$user,$pass);
if(!$connection){
        die("Database server connection failed.");
    }else{
 $dbconnect=mysql_select_db("profile",$connection);
if(!$dbconnect){
            die("Unable to connect to the specified database!");
        }else{
$username=$_GET["username"];
$password=$_GET["password"];
$query="SELECT id,profile_id,username,password from home where username='$username'and password='$password'";
$resultset=mysql_query($query,
            $connection);
$records=array();
if($resultset===false){
                die(mysql_error());
            }
while($r=mysql_fetch_row($resultset)){
                $records[]=$r;
            }
echo json_encode($records);
        }
    }?>

,错误为<?php$host="localhos^Expecting '{', '['

请解释一下我脚本中的问题在哪里。 我使用$_get[]方法通过我的数据库中的url输入详细信息,但我收到错误。它在localhost中工作,但不在验证器中工作。我只想在jsonlint中运行它。我该怎么做才能纠正它?

2 个答案:

答案 0 :(得分:1)

您确实错过了<?php$host之间的空格,因为解析器会在您的错误中向您说明。

答案 1 :(得分:0)

请保持一个空格

<?php$host="localhost"; sholud be corrected as `<?php $host="localhost";`