[英]mysqli bind_param (si) wont work
I am trying to insert a value to my database using mysqli bind_param. 我正在尝试使用mysqli bind_param向我的数据库插入一个值。
My code: 我的代码:
<?php
$stmt = $mysqli->prepare("
INSERT INTO ".$db_table_prefix."u_nm (uname,umobile) VALUES (?,?)");
$stmt->bind_param("si", $this->name, $this->mobile);
$stmt->execute();
$stmt->close();
?>
bind_param("s")
bind_param("s")
bind_param("i")
bind_param("i")
But the whole number wont insert if I put umobile as ("i")
? 但是如果我将umobile设置为
("i")
则不会插入整数?
Example: 例:
Lets say I insert the name Billy and the number 0739871169 可以说我输入了比利的名字和数字0739871169
Then inside the DB it would show up as: 然后在数据库内部,它将显示为:
Billy
739871169
instead of 代替
Billy
0739871169
But if I change bind_param to ("ss")
instead of ("si")
it works fine, 但是,如果我将bind_param更改为
("ss")
而不是("si")
则效果很好,
But shouldn't a number be marked as ("i")
or am I getting something wrong? 但是,数字不应该标记为
("i")
还是我输入错误?
It accepts the number as an integer (ie. no leading zeros). 它接受整数形式的数字(即没有前导零)。 You may add the "zerofill" option in the mobile phone field, or just accept it as a string.
您可以在手机字段中添加“ zerofill”选项,或仅接受它作为字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.