如何使用日语字符管理数据库中的ID

编程入门 行业动态 更新时间:2024-10-14 18:20:24
本文介绍了如何使用日语字符管理数据库中的ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

现在我有一个数据库。数据库使用全能utf-8排序规则进行编码。实际排序是utf8,我不知道什么编码是。这应该是另一个问题。

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; ?>

数据库的内容如下:

>

通过这样做(你需要放大你的屏幕看到它)调用函数:

Now I call the function by doing this (you need to enlarge your screen to see it):

localhost/domainname/api/test2.php?id=jr-東北本線-荒川橋梁__35.79_139.72

它不工作。

但是,如果我不使用$ _GET,但只需直接在代码中输入日语字符即可。

However, if I do NOT use $_GET but simply enter the Japanese characters directly in the code it works.

所以如果我改变:

$data = $_GET['id']

$data = 'jr-東北本線-荒川橋梁__35.79_139.72'

工作正常。

当然,我不想硬编码ID,我想通过$ _GET ['id']访问。我应该怎么办?

Of course, I don't want to hardwire the ID, I want to access that via $_GET['id']. What should I do?

推荐答案

只需使用 urlencode()字符串变成:

%E6%9D%B1%E5%8C%97%E6%9C%AC%E7%B7%9A- %E8%8D%92%E5%B7%9D%E6%A9%8B%E6%A2%81 。

检查rfc1738:统一资源定位器(URL)

Check rfc1738: Uniform Resource Locators (URL)

更多推荐

如何使用日语字符管理数据库中的ID

本文发布于:2023-11-02 03:58:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1551305.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:日语   数据库中   如何使用   字符   ID

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!