2016-09-02 11 views
-4

ラインにファイルの予期しない終わり:ガットPHP解析エラー:構文エラー、私はこのようなエラーを得た72

解析エラー:構文エラー、D内のファイルの予期しない終わり:XAMPP \ \ htdocsに\ spasial \ lokasiここでは、以下のこのコードの行72

上の.php:

<html> 
    <head>  
    <title>Latihan Google map</title> 
    <style type='text/css'> 
    #peta { 
    width: 50%; 
    height: 400px; 
    } </style> 
    <script type="text/javascript" src="http://maps.google.com/maps/api/js"></script> 
    <script type="text/javascript"> 
    (function() { 
    window.onload = function() { 
    var map; 
    var locations = [ 
<?php 
    //konfgurasi koneksi database 
     mysql_connect('localhost','root',''); 
     mysql_select_db('spasial'); 

      $sql_lokasi="select id,nama,lat,lng 
      from laswi"; 
      $result=mysql_query($sql_lokasi); 
      // ambil nama,lat dan lon dari table lokasi 
      while($data=mysql_fetch_object($result)){ 
       ?> 
     ['<?=$data->nama;?>', <?=$data->lat;?>, <?=$data->lng;?>],<? 
      } 
    ?>  

]; 

//Parameter Google maps 
var options = { 
    zoom: 12, //level zoom 
    //posisi tengah peta 
    center: new google.maps.LatLng(-6.924554, 107.627800), 
    mapTypeId: google.maps.MapTypeId.ROADMAP 
}; 

// Buat peta di 
var map = new google.maps.Map(document.getElementById('peta'), options); 
// Tambahkan Marker 

    var infowindow = new google.maps.InfoWindow(); 

var marker, i; 
/* kode untuk menampilkan banyak marker */ 
for (i = 0; i < locations.length; i++) { 
    marker = new google.maps.Marker({ 
    position: new google.maps.LatLng(locations[i][1], locations[i][2]), 
    map: map, 
    icon: 'icon.png' 
    }); 
/* menambahkan event clik untuk menampikan 
    infowindows dengan isi sesuai denga 
    marker yang di klik */ 

    google.maps.event.addListener(marker, 'click', (function(marker, i) { 
    return function() { 
     infowindow.setContent(locations[i][0]); 
     infowindow.open(map, marker); 
    } 
    })(marker, i)); 
    } 
}; 
})(); 
</script> 
</head> 
<body>  
<div id="peta"></div> 
</body> 
</html> 

だから私はすでにphp.iniファイルをオンにshort_open_tagが設定します。では、このコードの問題点は何ですか?

+0

PHPタグを混在させています。 '<?php'と' <? ' –

+0

どの行が72行目であるべきでしょうか? – Jens

+0

あなたの行番号72は、イベントはPHPコードを持っていません..どのようにエラーが来たのですか? –

答えて

-2
<?php 
//konfgurasi koneksi database 
    mysql_connect('localhost','root',''); 
    mysql_select_db('spasial'); 

     $sql_lokasi="select id,nama,lat,lng 
     from laswi"; 
     $result=mysql_query($sql_lokasi); 
     // ambil nama,lat dan lon dari table lokasi 
     while($data=mysql_fetch_object($result)){ 
      ?> 
    ['<?=$data->nama;?>', <?=$data->lat;?>, <?=$data->lng;?>], 

    <?php // <-- here 
     } 
?> 
+1

OPは短いタグが有効になっていて既に '<?'を持っていると言っています。 –

+0

そして何?ここで彼のエラーメッセージで説明する唯一の問題です。 – KoIIIeY

-1

あなたは?> -Endタグを設定しているが、あなたは<?phpでタグを開いていません。したがって、PHP-Interpretは、PHPコードが先に始まっていることを知りません。

<?phpをタグに入れてください。}はwhileループであり、これはPHPのコードであることを認識しています。

関連する問題