<?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");
}
?>
database.php中
<?php
$mysqli = new mysqli('localhost', 'php', 'passtheword', 'Android');
if($mysqli->connect_errno) {
printf("Connection Failed: %s\n", $mysqli->connect_error);
exit;
}
?>
由于某种原因,此查询未修改我的数据库。我知道&#39; database.php&#39;是有效的,我不会从if(!$ stmt)部分收到错误。没有什么打破,它只是没有修改表,Userinfo。谁能告诉我为什么?
答案 0 :(得分:3)
将$user
更改为$username
。您绑定并插入$username
,但只有$_POST
并定义$user