-1

我一直在搜索不同的站点以查看我做错了什么,但我不断收到 Parse 错误意外 $END。你能看看我的代码并告诉我我做错了什么吗?

     <!DOCTYPE html>
        <html>

    <head><meta name=Campus DrinkThink API Page/>
        <title> Campus DrinkThink API Page </title> 
    </head>
    <body>
    <?php


                // has the user taken the quiz before?
                if (isset($_COOKIE['visit_id'])) {                                                                  

        // if so, look up their answers in the JSON file
        $visit_id = $_COOKIE['visit_id'];                                                                
        $all_my_variables = json_decode(file_get_contents("/var/www/html/data/$visit_id.json"), TRUE);  
        $location= $all_my_variables -> location;

        echo "<h1>Your Night Out in Depth!</h1>";

        // make an API call to find what kind of place they typed in
        $google_maps_array = json_decode(
            file_get_contents( 'http://maps.googleapis.com/maps/api/geocode/json?address='.
                urlencode(
                    htmlspecialchars_decode(
                        $all_my_variables['location']
                    )
                ) . "&sensor=false"
            ), TRUE
        );
        $google_map_image= json_decode(file_get_contents("http://maps.googleapis.com/maps/api/staticmap?center=".
           urlencode($location)."&zoom=20&size=400x400"),
           TRUE
           );

            // remind them of their quiz answers
        echo "<p>When you used Campus DrinkThink";
        echo "You said that you were located at,: <b>";
        echo $all_my_variables['location'];                                                                 
        echo "</b>.</p>";     


        // handle the situation where there is no result
        if ($google_maps_array['status'] == 'ZERO_RESULTS')
            {                                           
            echo "<p>Google Maps can't find you at this time! Sorry!</p>";  
        // otherwise, if there is a result
    } else {            
            // output the place type by looking in the first [0] 
            // type element in the first [0] result element
            echo "<p>Google Maps says that this is a location type called: <strong>";
            echo $google_maps_array["results"][0]["types"][0];                                        
        echo "</strong></p>";

    }

    }else {  // no cookie is set                                                                      

            // you didn't use the app

        echo "<p>You have not yet used Campus DrinkThink</p>";
        print "<a href='http://haleysoehn.com/campusdrinkthink-form.html'> Click Here For the Quiz </a>";
        echo "Then return here to see your explained results";
    ?>

    </body>
</html> 
4

3 回答 3

3

这条线

    }else {  // no cookie is set    

缺少它的右括号}

于 2012-05-08T20:14:50.817 回答
1

您没有关闭在旁边打开的最后一个括号// no cookie is set

您应该使用带有语法突出显示的编辑器来提供帮助。Eclipse 不错,Notepad++ 也不错

于 2012-05-08T20:14:58.680 回答
0

您需要在第 12 行关闭此 if 语句:

if (isset($_COOKIE['visit_id'])) { 

您应该在 php 结束标记之前关闭它。

于 2012-05-08T20:16:35.260 回答