我已经尝试了删除查询的所有代码,它确实说'成功连接'但是当我放入数据时,它会出错。
这是我的html表单
<form action="testdel.php" method="post">
IC:
<input name="nama" type="text" />
<input name="Submit" type="submit" value="delete"/>
</form>
这是我的php:
<?php
$con=mysqli_connect("localhost", "root", "","jpn") or die("Cannot connect to
server.".mysqli_error($con));
$nama=@$_POST["nama"];
$sql_delete="DELETE FROM register WHERE nama='$nama' ";
$sql_result=mysqli_query($con,$sql_delete);
if ($sql_result)
echo "Succesfully deleted";
else
echo "error due to selected data";
?>
答案 0 :(得分:0)
<?php
$con = mysqli_connect("localhost", "root", "", "jpn") OR die("MySQL connection error");
if (isset($_POST['nama'])) {
$nama = $_POST['nama'];
$deleteQuery = "DELETE FROM register WHERE nama = '" . $nama . "'";
$delete = mysqli_query($con, $deleteQuery);
if ($delete) {
echo "Delete successful";
} else {
echo "Delete unsuccessful";
}
}
?>
如果您仍然收到错误,也许您可以详细说明您收到的错误消息。