您好我正在运行服务器端数据库来处理来自Android手机的输入。我有两个函数用于存储用户信息,另一个用于更新其位置。
存储位置的第二个我无法开始工作。
/**
* Storing new user
* returns user details
*/
public function storeUser($name, $email, $password) {
$uuid = uniqid('', true);
$hash = $this->hashSSHA($password);
$encrypted_password = $hash["encrypted"]; // encrypted password
$salt = $hash["salt"]; // salt
$result = mysql_query("INSERT INTO users(unique_id, name, email, encrypted_password, salt, created_at) VALUES('$uuid', '$name', '$email', '$encrypted_password', '$salt', NOW())");
// check for successful store
if ($result) {
// get user details
$uid = mysql_insert_id(); // last inserted id
$result = mysql_query("SELECT * FROM users WHERE uid = $uid");
// return user details
return mysql_fetch_array($result);
} else {
return false;
}
}
/**
* Updating a users
* location
*/
public function updateLocation($email, $location) {
$uuid = uniqid('', true);
$result = mysql_query("UPDATE users SET location='$location' WHERE email='$email' NOW())");
// check for successful store
if ($result) {
// get user details
$uid = mysql_insert_id(); // last inserted id
$result = mysql_query("SELECT * FROM users WHERE email = $email");
// return user details
return mysql_fetch_array($result);
} else {
return false;
}
}
非常感谢任何帮助。
由于
答案 0 :(得分:2)
查看更新查询$result = mysql_query("UPDATE users SET location='$location' WHERE email='$email' NOW())");
您似乎缺少部分内容。你需要告诉它需要设置为NOW(),也许是updated_at,"UPDATE users SET location='$location', updated_at = NOW() WHERE email='$email'"
答案 1 :(得分:0)
似乎您有错误:“WHERE email='$email' NOW())
”进入“created_at='NOW()' WHERE email='$email'
”
答案 2 :(得分:0)
你在SQL的末尾有一个额外的NOW()