문제

i have problem with unterminated string constant.

here is my code in PHP:

'html' => '<div><table><td><tr><img src="' . "http://www.simbawave.com/_lib/file/img/hotel/$FolderHotel/$NamaFile" . '"width="200" height="200" /></tr><tr><p><b>'.$Hotel."</b></p></tr></td><td>$Alamat</td></table></div>", 

and here is the HTML source (result, not all, it will be too long)

markers[8] = new google.maps.Marker({
    icon: "http://www.simbawave.com/MapBlueIcon/villa.png",
    title: "Bali Dynasty Resort",
    position: new google.maps.LatLng(-8.747509, 115.16764),
    map: map
});
infos[8] = new google.maps.InfoWindow({
    content: "<div><table><td><tr><img src=\"http://www.simbawave.com/_lib/file/img/hotel/HO-00009/depan2web.jpg\"width=\"200\" height=\"200\" /></tr><tr><p><b>Bali Dynasty Resort</b></p></tr></td><td> Jln. Kartika Po Box 2047
Tuban 80361
South Kuta
Bali - Indonesia</td></table></div>"
});

if i remove the variable $Alamat, it will be fine, no problem. but i ad $Alamat, i don't have any idea what's wrong with my PHP code.

The value of $Alamat is like that (string/varchar):

Jln. Kartika Po Box 2047
Tuban 80361
South Kuta

But in HTML view, it is shown only:

Jln. Kartika Po Box 2047

I thought there should be some characters are missing when passing to HTML.

Tuban 80361
South Kuta
Bali - Indonesia</td></table></div>

I thought those are the characters were not passed and make this error because the $Alamat contains multi lines not a single line while $Hotel contains a single line of string.

Anyone know how to make this varchar multi lines can be used in PHP?

올바른 솔루션이 없습니다

다른 팁

If you can try to not rely of PHP line breaks. Put in some <br />'s since you are passing HTML to the content anyways.

I too am having a similar issue, however, my HTML is properly formatted... I'll update this answer once I can get my issue figured out :), but for now, do a str_replace and replace all the PHP linebreaks \r & \n with a <br />

I have fixed my own issue, and wanted to share what I did with you.

function FormatMapContent($str){
    return str_replace(array('.', "\n", "\t", "\r"), '', $str); 
}

Wrap your InfoWindow content with that, and you should be good to go.

HTH ~Kevin

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top