参数编号无效:绑定变量的编号与php中数据库中的编号不匹配
输入格式代码为参数编号无效:绑定变量的编号与php中数据库中的编号不匹配,php,prepared-statement,Php,Prepared Statement,输入格式代码为 <form method="post" action="display.php" id="register-form" name="register-form" onsubmit="function() return false;"> <center> First Name :<pre> <input type = "text" name="firstname" value="" ></pre><br>
<form method="post" action="display.php" id="register-form" name="register-form" onsubmit="function() return false;">
<center> First Name :<pre> <input type = "text" name="firstname" value="" ></pre><br>
Last Name:<pre><input type="text" name = "lastname" value="" ></pre><br>
State:<pre><input type="text" name = "state" value="" ></pre><br>
City:<pre><input type="text" name = "city" value="" ></pre><br>
Mobile No:
<pre>
<input type="tel" id = "mobileno" name = "mobileno" data-validation="number" value="" ></pre><br>
Gender :<pre><ul type="none">
<li>Male: <input type="radio" name="icheck" value="Male">
Female: <input type="radio" name="icheck" value="Female" checked></li></ul></pre>
<input type="submit" name="add" value="ADD" formaction="add.php">
<input type="submit" name="delete" value="DELETE">
<input type="submit" name= "update" value="UPDATE" formaction="display.php"> </center>
</form>
名字:
姓氏:
状态:
城市:
手机号码:
性别:
- 男:
女:
php(文件)(从表单中插入值)
include(“dbconnect.php”)//数据库连接
$firstname=$_POST['firstname'];
$lastname=$\u POST['lastname'];
$state=$_POST['state'];
$city=strip_标签($_POST['city']);
$SEXT=strip_标签($_POST['icheck']);
$mobileno=(int)$_POST['mobileno'];
$query=“插入用户(姓氏、姓氏、州、城市、MobileNo、性别)值(?,,,,,,,,?)”;
$stmt=mysqli_prepare($dbc,$query)或die(mysqli_error());
$bind='ssssis';
mysqli_stmt_bind_param($stmt、$bind、$lastname、$firstname、$state、$city、$mobileno、$gender);
mysqli_stmt_execute($stmt);
如果(mysqli\u stmt\u受影响的行($stmt)==
1) {
echo'您的邮件已被删除
张贴。';
}否则{
echo'无法显示您的邮件
被张贴。
';
echo“”.mysqli\u stmt\u错误($stmt)。
“”;
}
//结束声明:
mysqli_stmt_close($stmt);
mysqli_close($dbc);
mobileno的输入值为7878,在数据库中显示为2147483647
我第二次输入的值是8787,它显示相同的值
所以代码只显示dimatch手机号码的错误。
谢谢 变化
到
参数不匹配并删除post手机号前面的int
MobileNo
的数据类型是什么?是字符串吗?不是。我在数据库中给了它int(10)默认int支持8个字符,改为double或stringu可以告诉我数据库中手机号码的列类型吗?它对我有用,谢谢!!我将mobileno的数据类型更改为数据库中的Bigint,并且还可以使用varchar f0r存储大的数字
include("dbconnect.php");//database connect
$firstname =$_POST['firstname'];
$lastname = $_POST['lastname'];
$state = $_POST['state'];
$city = strip_tags($_POST['city']);
$gender = strip_tags($_POST['icheck']);
$mobileno = (int) $_POST['mobileno'];
$query = "INSERT INTO user(LastName,FirstName,State,City,MobileNo,Gender) VALUES(?,?,?,?,?,?)";
$stmt=mysqli_prepare($dbc,$query) or die(mysqli_error());
$bind='ssssis';
mysqli_stmt_bind_param($stmt,$bind,$lastname,$firstname,$state,$city,$mobileno,$gender);
mysqli_stmt_execute($stmt);
if (mysqli_stmt_affected_rows($stmt) ==
1) {
echo '<p>Your message has been
posted.</p>';
} else {
echo '<p style="font-weight: bold;
color: #C00">Your message could not
be posted.</p>';
echo '<p>' . mysqli_stmt_error($stmt) .
'</p>';
}
// Close the statement:
mysqli_stmt_close($stmt);
mysqli_close($dbc);
$bind = 'ssssis';
$bind = 'ssssds';
$query = "INSERT INTO user(LastName,FirstName,State,City,MobileNo,Gender) VALUES(?,?,?,?,?,?)";
mysqli_stmt_bind_param($stmt, $bind, $lastname, $firstname, $state, $city, $mobileno, $gender);