[英]I am getting different number when I post (send) uuid to the server using android retrofit2
When I send UUID with android retrofit using post and store it to MySQL database I am getting different value, it is shorten and converted to numbers. 当我使用post发送带有android改造的UUID并将其存储到MySQL数据库时,我得到了不同的值,它被缩短并转换为数字。 Is there anything I have to do when I receive the UUID in PHP or when I store it to MySQL database table?
当我在PHP中收到UUID或将其存储到MySQL数据库表时,有什么要做的事情吗?
This is the UUID generated in my android application: 这是在我的Android应用程序中生成的UUID:
7cbb95ec-2de6-42a4-bd54-5a18b392ca03 7cbb95ec-2de6-42a4-bd54-5a18b392ca03
and when it is stored into the user table it become like this numbers: 当将其存储到用户表中时,它将变成以下数字:
795-26-424-54-51839203 795-26-424-54-51839203
Please can someone explain why this happening and how to fix? 请有人可以解释为什么会这样以及如何解决?
Api interface api界面
@FormUrlEncoded
@POST("insertdata.php")
Call<ResponseBody>insertdata(
@Field("userid")String userid,
@Field("articleid")int articleid);
Php insertdata.php PHP insertdata.php
if (isset($_POST['userid'])) {
$userid = filter_input(INPUT_POST, 'userid', FILTER_SANITIZE_NUMBER_INT);
} else {
die();
}
It's not a numerical value, so don't filter it like it is. 它不是数字值,所以请不要像这样对它进行过滤。 You're deleting the non-numerical characters.
您正在删除非数字字符。 Don't
filter_input
, just leave it alone. 不要
filter_input
,就别filter_input
。
For SQL injection issues, as always, use prepared statements with placeholder values . 与往常一样,对于SQL注入问题,请使用带有占位符value的准备好的语句 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.