gpt4 book ai didi

php - 警告:mysqli_error()期望恰好有1个参数,在register.php文件中给出的0个参数

转载 作者:行者123 更新时间:2023-11-29 19:21:18 24 4
gpt4 key购买 nike

我完全按照w3schools.com ..中的代码进行操作,但是仍然出现上述错误,并且数据库表也未更新。

我的html和php代码如下:

<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);
?>

最佳答案

我听错了,这是

mysqli_error()语法错误。

更改

die('Error: ' . mysqli_error());




die('Error: ' . mysqli_error($con));

关于php - 警告:mysqli_error()期望恰好有1个参数,在register.php文件中给出的0个参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42428791/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com