我正在尝试将数据插入到我的 MySQL 表中,但没有运气。我的代码如下所示:
$mysqli = mysqli_connect("localhost","login info");
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
if (isset($_POST['submit'])) {
$number = $_POST['number'];
$road = $_POST['road'];
$postcode=$_POST['postcode'];
$price=$_POST['price'];
$type=$_POST['type'];
$bedrooms=$_POST['bedrooms'];
$agent=$_POST['agent'];
$featured=$_POST['featured'];
$keywords=$_POST['keywords'];
$mysqli->query("
INSERT INTO listings-rent
(number, road, postcode, price, type, bedrooms, agent, featured, keywords)
VALUES
('$number','$road','$postcode','$price','$type','$bedrooms','$agent','$featured','$keywords')");
}
连接很好,没有返回错误。