我是新手,請耐心等待我想創建一個將數據添加到MariaDB的HTML表單。基本!但我不能夠PHP7-MariaDB插入數據表格
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<meta charset="utf-8" />
<head>
<title>PAGINA CARICAMENTO DATI</title>
</head>
<body>
<table border="0">
<tr>
<td align="center">Inserisci i dati richiesti</td>
</tr>
<tr>
<td>
<table>
<form method="post" action="input.php">
<tr>
<td>Nome</td>
<td><input type="text" name="name" size="20">
</td>
</tr>
<tr>
<td>Cognome</td>
<td><input type="text" name="surname" size="20">
</td>
</tr>
<tr>
<td>Città</td>
<td><input type="text" name="city" size="20">
</td>
</tr>
<tr>
<td></td>
<td align="right"><input type="submit"
name="submit" value="Sent"></td>
</tr>
</form>
</table>
</td>
</tr>
</table>
</body>
</html>
和PHP的部分是:
<?php
$host='localhost';
$user='root';
$password='password';
$database='esempio';
$connection = mysqli_connect($host,$user,$password,$database);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$name = $_POST['name'];
$surname = $_POST['surname'];
$city = $_POST['city'];
printf($name);
printf($surname);
printf($city);
$sql="INSERT INTO people (ID,Name,Surname,City)VALUES(default,$name,$surname,$city)";
printf($sql);
if(!mysqli_query($connection,$sql)){
printf("Errore: %s\n",mysqli_error($connection));
}
mysqli_close($connection);
?>
MariaDB的有4列:
- ID指數INT(11)否無AUTO_INCREMENT更改更改 Drop Drop
- 名稱tinytext utf8_general_ci沒有沒有更改修改刪除刪除
- 姓TINYTEXT utf8_general_ci否無 更改更改刪除刪除
- 市TINYTEXT utf8_general_ci 否無更改更改刪除刪除
你收到了什麼錯誤和在哪一行? –
'字段列表'中的未知列'pippo' –
您可以發佈表示錯誤發生在 –