gpt4 book ai didi

php - 警告:mysqli_error()需要在register.php文件中给出1个参数0

转载 作者:可可西里 更新时间:2023-11-01 07:22:53 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()需要在register.php文件中给出1个参数0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16029273/

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