我正在编写一个带有数据库的脚本,但是我已经很长时间了解这些东西并且它一直给我错误,这对你们来说很容易=)
我想要输入这个
<body>
<hr> bestelling <hr>
<form action="bestellingopslaan.php" method="post">
Bestelnummer <input name="bestelnummer" type="text"> <br>
Klantnaam <input name="klantnaam" type="text"> <br>
Artikel<input name="artikel" type="text"> <br>
Prijs <input name="prijs" type="text"> <br>
<input name="verzenden" type="submit" value="Verzenden" />
</form>
到这个页面
<body>
bestelling opslaan
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$dbname = '11092068';
//connection to the database
$dbhandle = mysql_connect($dbhost, $dbuser, $dbpass)
Or die("couldn't connect to SQL Server on $dbhost");
//select a database to work with
$selected = mysql_select_db($dbname, $dbhandle)
Or die("couldn't open database $dbname");
//maak de query
$insert_query = "INSERT INTO bestelling ('$_POST[bestelnummer]', '$_POST[klantnummer]', '$_POST[artikel]', '$_POST [prijs]' ) ";
if (mysql_query( $insert_query, $dbname))
{
echo "de gegevens zijn opgeslagen in de database";
}
else
{
echo "foutje";
}
?>
</body>
</body>
以下是我的数据库的截图
所以,我希望你们能帮助我。
答案 0 :(得分:0)
很高兴看到你的错误,但是看看你的代码看起来你在查询中找到了VALUES ....它应该是INSERT INTO table_name (column1, column2 ,etc) VALUES
.....