一切正常,只有 UPDATE 命令不起作用:
$con = mysql_connect($dburl, $dbuser, $dbpass);
if (!$con) {
die('Could not connect: '.mysql_error());
}
mysql_select_db($dbname, $con);
$result = mysql_query("SELECT * FROM $dbtable WHERE user = '$user'");
$token = generateToken();
if (!empty($result)) {
// check for empty result
if (mysql_num_rows($result) > 0) {
$result = mysql_fetch_array($result);
if (strcmp($result["pass"], $pass) == 0) {
$client = array();
$client["Credential"] = $token;
mysql_query("UPDATE $table SET credential='$token'
WHERE user='$user' && pass='$pass'", $con);
print(json_encode($client));
}
else {
$client["success"] = "0";
print(json_encode($client));
}
}
else {
// no product found
$client["success"] = "0";
print(json_encode($client));
}
}
else {
$client["success"] = "0";
print(json_encode($client));
}
mysql_close($con);
我需要更新登录中的凭证令牌。mysql_query("UPDATE $table SET credential='$token' WHERE user='$user' && pass='$pass'", $con);