问题描述
我有一张包含人员列表的表格,我想有一个选项,您可以在其中编辑所列人员的信息。我有一个editperson.php文件和一个editsql.php文件。我在尝试为这些人提交新值时遇到这些错误:
点击此处 - > []
这是editperson.php的代码
I have a table with a list of people, and I want to have a option where you can edit the information shown of those people listed. I have a editperson.php file and a editsql.php file. I get these errors when trying to submit new values for the persons:
Click here -> https://gyazo.com/5e5e52c26b1b978d7802f58eaafba16d[^]
Here is the code for editperson.php
<!doctype html>
<html>
<body>
Skriv inn nye verdier for denne personen
<form action = 'editsql.php' method = 'POST'>
<?php
include('oppkobling.php');
$id = $_POST['id'];
// Lag SQL-setning
$query = 'SELECT * FROM rikestemennesker WHERE id = '.$id;
// Kjør spørringen
$resultat = mysqli_query($db, $query);
$rad = mysqli_fetch_array($resultat);
//echo "<input type = 'hidden' name = 'editmnr' value = ".$id.">";
echo "Plass: <input type = 'text' value = '".$rad['id']."' size='30'
name='editplass'><br>";
echo "Navn: <input type = 'text' value = '".$rad['Navn']."' size='30'
name='editnavn'><br>";
echo "Land: <input type = 'text' value = '".$rad['Land']."' size='30'
name='editland'><br>";
echo "Nettoformue: <input type = 'text' value =
'".$rad['Nettoformue']."' size='50' name='editformue'><br>";
echo "Kilde: <input type='text' value = '".$rad['Kilde']."' size ='50'
name ='editkilde'><br>";
// Koble ned
mysqli_close($db);
mysqli_free_result($resultat);
?>
<input type = 'submit' value = 'Oppdater'>
</form>
</body>
</html>
和这里是editsql.php的代码
and here is the code for editsql.php
<?php
include('oppkobling.php');
$n = $_POST['editnavn'];
$a = $_POST['editformue'];
$l = $_POST['editland'];
$m = $_POST['editplass'];
$k = $_POST['editkilde'];
$query = "UPDATE rikestemennesker SET
navn = '$n',
land = '$l',
formue = '$a',
kilde = '$k',
WHERE plass = $m";
mysqli_query($db, $query);
mysqli_close($db);
header("Location: index.php");
?>
我有什么试过:
我试图查看所有变量,并检查代码是否链接到数据库
What I have tried:
I have tried to look over all variables, and checked that the code is linked to the database
推荐答案
这篇关于我该如何解决这些错误?请帮我解决这个PHP / SQL表问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!