本文介绍了警告:mysqli_error()期望恰好有1个参数,在register.php文件中给出的0个参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我严格按照w3schools.com中的代码进行操作..但仍然出现上述错误,并且数据库表也未更新.
I followed the code exactly as in w3schools.com..but still I am getting the above error and the database table is also not updated.
我的html和php代码如下:
My html and php code is as follows :
<form action="register.php" method="post">
<select name="title" size="1">
<option>Mr.</option>
<option>Ms.</option>
<option>Prof.</option>
<option>Dr.</option>
</select>
<label class="label">Given Name: <input name="givenname" type="text" value="Enter Your First Name" maxlength="30" /></label>
<label class="label">Surname: <input name="surname" type="text" /></label>
<label class="label">Address: <input name="address" type="text" maxlength="80" /></label>
<label class="label">Phone No: <input name="phoneno" type="text" /></label>
<label class="label">Email ID: <input name="emailid" type="text" /></label>
<label class="label">Fax: <input name="fax" type="text" /></label>
<label class="label">Pincode: <input name="pincode" type="text" /></label>
<label class="label">Country: <input name="country" type="text" /></label>
<input name="submit" type="submit" />
</form>
<?php
$con=mysqli_connect("my_Ipaddress","abcd","abcd");
//database connection
if (mysqli_connect_errno())
{
echo "Failed to connect to Database...There must be some error! We are working on it!!" . mysqli_connect_error();
}
$sql="INSERT INTO Registrations (Title, Given Name, Surname, Address, Phone No, Email ID, Fax, Pincode, Country)
VALUES ('$_POST[title]','$_POST[givenname]','$_POST[surname]','$_POST[address]','$_POST[phoneno]','$_POST[emailid]','$_POST[fax]','$_POST[pincode]','$_POST[country]')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error());
}
echo "1 record added";
mysqli_close($con);
?>
推荐答案
我收到了您的错误,这里是
I got your error, here it is
mysqli_error()语法错误.
mysqli_error() syntax is wrong.
更改
die('Error: ' . mysqli_error());
到
die('Error: ' . mysqli_error($con));
这篇关于警告:mysqli_error()期望恰好有1个参数,在register.php文件中给出的0个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!