我只是在进行一些测试,但我无法确定我是否以正确的方式进行了操作。查询将会更新该行记录,但受影响的行数总是返回 0。为什么?
<?php
$connection = new mysqli('localhost', 'user', 'pass', 'db');
if (mysqli_connect_errno()) {
printf("Can't connect to MySQL Server. Errorcode: %s\n", mysqli_connect_error());
exit;
}
$email = $connection->real_escape_string($_GET['email']);
$activation = $connection->real_escape_string($_GET['hash']);
//$query = $connection->query("SELECT email, activationCode, active FROM users WHERE email='".$email."' AND hash='".$activation."' AND active='0'");
$select = $connection->query("UPDATE users SET active = '1' WHERE email='".$email."' AND activationCode='".$activation."' AND active='0'");
printf("Affected rows (UPDATE): %d\n", $select->affected_rows);
$connection->close();
?>