【发布时间】:2015-01-16 16:08:36
【问题描述】:
我们使用 Xampp 来模拟 apache 和 mysql 服务器。 我不知道到底是什么问题。当我检查数据库时,它没有任何价值。
数据库:http://de.tinypic.com/r/53285/8
这是我的 html 代码:
<!DOCTYPE html>
<html>
<body>
<form action="data.php" method="POST">
<input type="radio" name="Color" value="b" id="r"/>
<label for="radio">ROT</label></br>
<input type="radio" name="Color" value="b" id="g"/>
<label for="radio">GRÜN</label></br>
<input type="radio" name="Color" value="b" id="b"/>
<label for="radio">BLAU</label></br>
<button type="submit">Absenden</button>
</form>
</body>
</html>
这是我的 php 代码:
<?php
$db = mysqli_connect("localhost", "root", "", "lightcontrol");
if(!$db)
{
exit("Verbindungsfehler: ".mysqli_connect_error());
}
if(isset($_POST["Color"]))
{
if($_POST["Color"]=="r")
{
$variable =" INSERT INTO valuetb VALUES(`1`,,`255`,`0`,`0`)";
}
if($_POST["Color"]=="g")
{
$variable =" INSERT INTO valuetb VALUES(`1`,,`0`,`255`,`0`)";
}
if($_POST["Color"]=="b")
{
$variable =" INSERT INTO valuetb VALUES(`1`,,`0`,`0`,`255`)";
}
}
var_dump($variable);
mysqli_query($db,$variable);
?>
【问题讨论】:
-
我认为您的查询完全错误。你能告诉我们你的数据库表是什么样子的吗?
标签: php mysql html apache xampp