我是PHP的新手。我必须更新特定ID的数据。我正在使用准备好的语句进行更新。但是出现很多错误...任何人都可以帮助我解决这个错误。
我尝试了正常的更新查询。它工作正常。但是当我使用准备好的语句时。我遇到了错误。
<?php
if (isset($_POST['submit'])) {
// Assigning to variables
// Assigning to variables
$domain = $_POST['domain'];
$project_name = $_POST['project_name'];
$contact_number = $_POST['contact_number'];
$contact_person = $_POST['contact_person'];
$domain_setup = $_POST['domain_setup'];
$hosting_setup = $_POST['hosting_setup'];
$expiry_date = $_POST['expiry_date'];
$period = $_POST['period'];
$cpanel_name = $_POST['cpanel_name'];
$cpanel_password = $_POST['cpanel_password'];
$wp_username = $_POST['wp_username'];
$wp_password = $_POST['wp_password'];
$domain_mails = $_POST['domain_mails'];
$domain_host = $_POST['domain_host'];
$domain_username = $_POST['domain_username'];
$domain_password = $_POST['domain_password'];
$place = $_POST['place'];
$extra_notes = $_POST['extra_notes'];
// mysqli_connect() function opens a new connection to the MySQL server.
$conn = mysqli_connect("localhost", "root", "", "mydomain");
// SQL query to insert information of register table.
// prepare and bind
$sql = $conn->prepare("UPDATE domin_register
SET domain= ?, project_name= ?, contact_number= ?,
contact_person= ?, domain_setup= ?, hosting_setup= ?,
expiry_date= ?, period= ?, cpanel_name= ?,
cpanel_password= ?, wp_username= ?, wp_password= ?,
domain_mails= ?, domain_host= ?, domain_username= ?,
domain_password= ?, place= ?, extra_notes=?
WHERE domain_id = ?");
$stmt = mysqli_stmt_init($conn);
mysqli_stmt_bind_param($stmt,'ssssssssssssssssss',
$domain, $project_name, $contact_number,
$contact_person, $domain_setup, $hosting_setup,
$expiry_date, $period, $cpanel_name, $cpanel_password,
$wp_username, $wp_password, $domain_mails, $domain_host,
$domain_username, $domain_password, $place, $extra_notes);
mysqli_stmt_execute($stmt);
$stmt->execute();
$stmt->close();
}
?>
我想用错误更新数据
我的错误如下:
警告:mysqli_stmt_bind_param():第213行的D:\ Xampp \ htdocs \ mydomain \ updatedata.php中的无效对象或资源mysqli_stmt
警告:mysqli_stmt_execute():无效的对象或资源mysqli_stmt位于214行的D:\ Xampp \ htdocs \ mydomain \ updatedata.php中
警告:mysqli_stmt :: execute():第215行的D:\ Xampp \ htdocs \ mydomain \ updatedata.php中无效的对象或资源mysqli_stmt
警告:mysqli_stmt :: close():第216行的D:\ Xampp \ htdocs \ mydomain \ updatedata.php中的无效对象或资源mysqli_stmt