我正在尝试创建一个从html表单中获取数据并将其添加到sql数据库的网站
post.html:
<form action="send_post.php" method="post">
<h3>ID:</h3>
<input type="text" name="id">
<h3>Name:</h3>
<input type="text" name="name">
<h3>Surname:</h3>
<input type="text" name="surname">
<input type="submit">
send_post.php
<?php
$connect = mysqli_connect("myhost","myusername","mypassword","myDB");
mysqli_query($connect,"INSERT INTO test_table (id, name, surname)
VALUES ('$_POST[id]', '$_POST[name]', '$_POST[surname]')"
?>
我托管了它here
然而,当我尝试时,它表示在没有半结肠的行中有一个意外的分号。我该如何解决这个问题?
答案 0 :(得分:3)
缺少);
使用此...
mysqli_query($connect,"INSERT INTO test_table (id, name, surname)
VALUES ('$_POST[id]', '$_POST[name]', '$_POST[surname]')");