首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >特殊字符提供的值为空值

特殊字符提供的值为空值
EN

Stack Overflow用户
提问于 2012-11-08 13:13:30
回答 2查看 438关注 0票数 0

我有1个database.In,我有1个tabel。我在这段代码中做json解析。

我使用这个php代码来检索值:

代码语言:javascript
复制
<head>
<style type="text/css">
.auto-style1 {
    text-align: right;
}
</style>
</head>

<?php

echo getdata($_REQUEST['lastupdate']);

function getdata($lastupdatedate){


    $obj = json_decode($json);



    $con = mysql_connect("localhost","root","Password");


    if (!$con)
    {
        die('Could not connect: ' . mysql_error());
    }
    mysql_select_db("roster", $con);

    $query = "select * from statedeathtax_v2 where LastUpdated > '".$lastupdatedate."' order by LastUpdated";

    $rs = mysql_query($query) or die($query);

    //print_r($rs);

    while($row=mysql_fetch_assoc($rs)){

    $record[] = $row;

    }



    $data = json_encode($record);



    header('Cache-Control: no-cache, must-revalidate');

    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');

    header('Content-type: application/json');

    return $data;

}

?>

在这里,这段代码没有显示"$“这样的特殊字符。当我在这段代码中抛出查询时,它显示了具有特殊字符的列的空值。我不明白这个问题。

EN

Stack Overflow用户

回答已采纳

发布于 2012-11-08 20:11:34

我已经解决了问题:

更新的代码:

代码语言:javascript
复制
<?php

echo getdata($_REQUEST['lastupdate']);

function getdata($lastupdatedate){


    $obj = json_decode($json);



    $con = mysql_connect("localhost","root","Password@123");
    mysql_set_charset('utf8',$con);

    if (!$con)
    {
        die('Could not connect: ' . mysql_error());
    }
    mysql_select_db("roster", $con);

    $query = "select * from statedeathtax_v2 where LastUpdated > '".$lastupdatedate."' order by LastUpdated";

    $rs = mysql_query($query) or die($query);

    //print_r($rs);

    while($row=mysql_fetch_assoc($rs)){

    $record[] = $row;

    }



    $data = json_encode($record);



    header('Cache-Control: no-cache, must-revalidate');

    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');

    header('Content-Type: application/json; charset=utf-8' );

    return $data;

}

?>
票数 0
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13282835

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档