gpt4 book ai didi

php - 为什么这段访问 MySQL 数据库的 PHP 代码不起作用?

转载 作者:太空宇宙 更新时间:2023-11-03 12:12:22 24 4
gpt4 key购买 nike

<分区>

<?php

require('database.php');
$user = $_POST["username"];
$password = $_POST["password"];
$location = $_POST["location"];

$stmt = $mysqli->prepare("insert into Userinfo (username, password, location) values (?, ?, ?)");
if(!$stmt) {
//printf("Query prep failed: %s\n", mysqli->error);
echo "query prep failed".$mysqli->error;
exit;
}
$stmt->bind_param('sss', $username, $password, $location);
$stmt->execute();
$stmt->close();
error_log("username ".$user, 3, "/tmp/php_error.log");
}
?>

数据库.php

<?php

$mysqli = new mysqli('localhost', 'php', 'passtheword', 'Android');

if($mysqli->connect_errno) {
printf("Connection Failed: %s\n", $mysqli->connect_error);
exit;
}
?>

出于某种原因,此查询未修改我的数据库。我知道“database.php”是有效的,而且我没有从 if(!$stmt) 部分收到错误。没有中断,它只是不修改表,Userinfo。谁能告诉我为什么?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com