私はこの小さなグレムリンを修正できないようです。
テーブルに説明フィールドがあるmySQLデータベースがあります。
私のクライアントは'文字をかなり頻繁に使用しており、これは私がphpから生成しているjsonを壊しています。
私のスクリプトは次のとおりです。
... database call...
$totalRows_rs_results = mysql_num_rows($rs_results);
if($totalRows_rs_results >0){
$myData = array();
//echo('locations near this unitbase:');
$myData['id'] = $row_rs_results['id_loc'];
$myData['slug'] = $row_rs_results['slug_loc'];
$myData['name'] = $row_rs_results['name_loc'];
$myData['showname'] = $row_rs_results['showname_loc'];
$myData['description'] = utf8_encode($row_rs_results['description_loc']);
$myData['image'] = getDefaultLocationImage($database_reelfilm, $reelfilm, $row_rs_results['id_loc']);
$myAddress = ($row_rs_results['address_loc'].' '.$row_rs_results['postcode_loc']);
$myData['address'] = $myAddress;
$myData['maplat'] = $row_rs_results['maplat_loc'];
$myData['maplong'] = $row_rs_results['maplong_loc'];
$myData['parking'] = $row_rs_results['parkinginfo_loc'];
$myData['features'] = $row_rs_results['internalfeatures_loc'] . ' ' . $row_rs_results['externalfeatures_loc'];
//$myData['categorys'] = getCategorys($database_reelfilm, $reelfilm, $row_rs_results['id_loc']);
$json[] = $myData;
$myJSON = json_encode($json);
return $myJSON;
};
<span class='showOnMap' data-location='<?php echo makeJSON($database_reelfilm, $reelfilm, 'location', $row_rs_locations['id_loc']);?>' '>
<img src="/images/Icons/map-icon.png" width="32" height="32">
</span>
出力されたjsonは、前述の'文字のレコードに到達するまでは問題ありません。
レコードから問題のある文字を削除すると、正しい出力が得られます。
<span class="showOnMap" data-related="" data-categorys="" data-location="[{"id":"29","slug":"the-butts","name":"The Butts","showname":"1","description":"Controllable period street location. Looks like an A road or a bus route. Surrounding houses are Georgian or early Victorian.","image":"The Butts 3.jpg","address":"Brentford\r\nLondon TW8 8BQ","maplat":"51.4847373","maplong":"-0.30824250000000575","parking":"","features":" "}]">
<img width="32" height="32" src="/images/Icons/map-icon.png">
</span>
'文字で生成されたデータ出力:
<span class="showOnMap" data-related="" data-categorys="" "}]'="" 8bq","maplat":"51.4847373","maplong":"-0.30824250000000575","parking":"","features":"="" tw8="" 3.jpg","address":"brentford\r\nlondon="" butts="" victorian.","image":"the="" early="" georgian="" are="" houses="" surrounding="" route.="" bus="" a="" or="" road="" a'="" data-location="[{"id":"29","slug":"the-butts","name":"The Butts","showname":"1","description":"Controllable period street location. Looks like an ">
<img width="32" height="32" src="/images/Icons/map-icon.png">
</span>
今では、クライアントに問題のあるすべての文字(1000を超えるレコードがある)を調べて削除するように指示することは、私には非常に専門的ではないようです。
htmlspecialchars()、utf8_encode()を試して問題を修正しましたが、どちらを使用する必要があるかわからないので、誰かが私を正しい方向に向けてくれませんか?