0

我在尝试设置轮询脚本时遇到问题...该脚本在我的本地主机上运行良好,但是当我将其传输到实时服务器时,我排除了一些错误...我的本地 php 版本是 5.3.8 和实时服务器是 5.2.13 ....投票更新数据库。我将其缩小到 json_encode 的问题...它没有调用 javascript,iv 阅读了大量帖子但找不到答案...这是一些代码片段

    include_once ('db_connect.php');
    include_once ('functions.php');

    if ( isset($_POST['poll']) and isset($_POST['option'])){

        $poll_id = intval($_POST['poll']);
        $option_id = intval($_POST['option']);

            add_vote( $option_id,$poll_id );
            setcookie('poll_'.$poll_id, 1, time() * (60 * 60 * 5),'/');

            exit( json_encode(array('results' => results($poll_id))));
    }

这是javascript

       $("img", form).remove();
        //set the new options Percentages
        $.each(data.results, function (option, value) {
            $("p#option_" + option).find("span").show().css({
                width: 0,
                opacity: 0
            }).animate({
                width: value + "%",
                backgroundColor: getColorForPercentage(value / 100),
                opacity: 1
            }, "slow", "swing", function () {
                $("p#option_" + option).find("em").text(value + "%").fadeIn("slow");
            })
        });

    }, "json");
    return false;

它绝对让我崩溃......如果尝试这么费力......把exit(); 在 json_encode 之后...

任何帮助都会非常感激......

谢谢

4

1 回答 1

0

您需要删除以下警告和任何额外的输出。

<br />
<b>Warning</b>:  Expiry date cannot have a year greater then 9999 in <b>/content/Hosting/o/p/opinionfreaks.com/web/vote.php</b> on line <b>11</b><br />
string(53) "{"results":{"1":46.7,"2":10,"3":26.7,"4":10,"5":6.7}}"

或者你可以做error_reporting(E_ERROR);,但仍然是<br />打印。

也考虑以下:

setcookie('poll_'.$poll_id, 1, time() + (60 * 60 * 5),'/'); // its + not *
于 2012-10-12T09:19:06.060 回答