Now I got a database. The database is encoded with the almighty utf-8 collation. Actually collation is utf8, I am not sure what the encoding is. That should be another question.
Then I made a program to retrieve data from the database.
<?php
require_once('convertArraytoJson.php');
require_once('config.php');
mysql_connect ( "localhost", $databaseuser, $databasepassword);
mysql_query("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'");
@mysql_select_db ($databasename) or die ( "Unable to select database" );
$data=$_GET['id'];
$query="SELECT * FROM `tabletes` where id = '".$data."'";
$data = mysql_query($query);
while (true){
$info = mysql_fetch_array ( $data, MYSQL_ASSOC );
if ($info == false) {
break;
}
//$output[]=$info;
$output[$info['ID']]=$info;
unset ($output[$info['ID']]['ID']);
}
$result = array2json($output);
echo $result;
?>
The content of the database looks like this:
Now I call the function by doing this (you need to enlarge your screen to see it):
http://localhost/domainname/api/test2.php?id=jr-東北本線-荒川橋梁__35.79_139.72
It doesn't work.
However, if I do NOT use $_GET but simply enter the Japanese characters directly in the code it works.
So if I change:
$data = $_GET['id']
to
$data = 'jr-東北本線-荒川橋梁__35.79_139.72'
Things are working fine.
Of course, I don't want to hardwire the ID, I want to access that via $_GET['id']. What should I do?