我正在尝试在 mysql 数据库中存储电话号码。但它存储了不同的值。
<form align="center" method="post" action="sendingdata.php" enctype="multipart/form-data">
<label for="phone">Phone Number </label></br>
<input type="number" name="phone" id="phone" placeholder="90000 12345"/>
<input class="submit" type="submit" />
以下是sendingdata.php
$phone = $_POST['phone'];
$q = sprintf("insert into posts(title,price,description,imagepath,name,phone) values('%s',%d,'%s','%s','%s','%d')", mysqli_real_escape_string($conn, $title), mysqli_real_escape_string($conn, $price), mysqli_real_escape_string($conn, $description), mysqli_real_escape_string($conn, $imageName),mysqli_real_escape_string($conn, $username),mysqli_real_escape_string($conn, $phone));
if (mysqli_query($conn, $q)) {
header('Location: index.php');
echo "success";
}
我尝试输入的值是90000 00000。但是数据库中存储的值是2147483647
ps:mysql中的数据类型为BIG INT
最佳答案
那就是maximum INT
大小。考虑使用 BIGINT
或 VARCHAR
column ,或具有固定宽度的 CHAR
列。
INT
的最大大小为“2147483647”(有符号)和“4294967295”(无符号)。而固定长度的 CHAR
可以是任意 X 位/字符长的数字。如果您使用 CHAR
或 VARCHAR
列,请务必先验证您的输入,因为它允许值中包含多个数字。
关于php - Mysql存储数字的方式不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29849082/