mysqli data INSERT not working but there are no errors
i just started with mysqli and i dont really know everything good
i also saw the other questions about it but none of the solutions works for me
this is the form:
<head>
<title>NEW</title>
</head>
<body>
<table border="1">
<tr>
<td align="center">NEW</td>
</tr>
<tr>
<td>
<table>
<form method="post" action="add.php">
<tr>
<td>name</td>
<td><input type="text" name="name" size="20">
</td>
</tr>
<tr>
<td>type</td>
<td><select name="ptype">
<option value="a1">a1</option>
<option value="a2">a2</option>
<option value="a3">a3</option>
</select>
</td>
</tr>
<tr>
<td></td>
<td align="right"><input type="submit"
name="submit" value="GO"></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
this is the add.php file:
<?php
require("dbconnect.php");
if (isset($_POST['submit'])) {
$db->query("SET NAMES 'utf8'");
$stmt = $db->prepare("INSERT INTO `business` (`ptype`, `name`) VALUES (?, ?)");
$stmt->bind_param('ss', $ptype, $name);
$name = $_POST["name"];
$ptype = $_POST["ptype"];
printf("%d Row inserted.\n", $stmt->affected_rows);
/* close statement and connection */
$stmt->close();
/* close connection */
}
$db->close();
?>
and it says that 0 row inserted
- the dbconnect.php file contains the connection to mysqli
Change
to