我只是在做一些测试,我不知道我是否以正确的方式做这件事。查询将更新该行。但affected_rows 总是返回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();
?>