您好我有一个基本的HTML表单 Index.html
<html>
<body>
<form action="update.php" method="POST">
Department: <input type="text" name="department"><br><br>
Subname: <input type="text" name="subname"><br><br>
Labels: <input type="text" name="labels"><br><br>
Pagerduty: <input type="text" name="pagerduty"><br><br>
Description: <input type="text" name="description"><br><br>
<input type="submit" value="Submit" name="submit">
</form>
</body>
</html>
在提交时,执行以下PHP脚本以更新我的数据库的详细信息。的 update.php
<?php
$hostname = "localhost";
$username = "root";
$password = "xxxxxxxxxxx";
$db = "dora";
$dbconnect=mysqli_connect($hostname,$username,$password,$db);
if ($dbconnect->connect_error) {
die("Database connection failed: " . $dbconnect->connect_error);
}
if(isset($_POST['submit'])) {
$department=$_POST['department'];
$subname=$_POST['subname'];
$labels=$_POST['labels'];
$pagerduty=$_POST['pagerduty'];
$description=$_POST['description'];
$query = "INSERT INTO dora (department, subname, labels, pagerduty, description)
VALUES ('$department', '$subname', '$labels', '$pagerduty', '$description')";
if (!mysqli_query($dbconnect, $query)) {
die('An error occurred when submitting your review.');
} else {
echo "Thanks for your review.";
}
}
?>
然后我想要另一个页面显示一个HTML表格,其中包含来自DB Main.html
的内容<html>
<body>
<?php
$hostname = "localhost";
$username = "root";
$password = "xxxxxxxx";
$db = "dora";
$dbconnect=mysqli_connect($hostname,$username,$password,$db);
if ($dbconnect->connect_error) {
die("Database connection failed: " . $dbconnect->connect_error);
}
?>
<table border="1" align="center">
<tr>
<td>Department</td>
<td>Subname</td>
<td>Labels</td>
<td>Pagerduty</td>
<td>Description</td>
</tr>
<?php
$query = mysqli_query($dbconnect, "SELECT * FROM dora")
or die (mysqli_error($dbconnect));
while ($row = mysqli_fetch_array($query)) {
echo
"<tr>
<td>{$row['department']}</td>
<td>{$row['subname']}</td>
<td>{$row['labels']}</td>
<td>{$row['pagerduty']}</td>
<td>{$row['description']}</td>
</tr>\n";
}
?>
</table>
</body>
</html>
除了两列没有映射之外,一切正常,即Subname & Labels
我已经仔细检查了我的代码,但我无法发现错误,任何人都可以帮助我吗?
我重新启动了https等,但似乎没有任何效果:(
DORA SCHEMA
MariaDB [dora]&gt;显示dora中的列;
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| TAB_ID | int(11) | NO | PRI | NULL | auto_increment |
| department | varchar(200) | YES | | NULL | |
| subname | varchar(200) | YES | | NULL | |
| labels | varchar(200) | YES | | NULL | |
| pagerduty | varchar(200) | YES | | NULL | |
| description | varchar(200) | YES | | NULL | |
+-------------+--------------+------+-----+---------+----------------+
我的表格
的结果Department Subname Labels Pagerduty Description
1 4 5
1 4 5
sdfsdf adfasdfad adfadfadfa
答案 0 :(得分:1)
我测试了你的代码,它运行正常。唯一的区别是我使用的InnoDB应该是相同的。请尝试以下方法:
1更改这些列名称。
2重新创建您的数据库。
3确保没有trigers将两列设置为木板