-1

一切正常,只有 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);

4

1 回答 1

2

此(第二)行不正确(已在您的问题中编辑/更正,如果同行/查看/接受)

// check for empty result
if (mysql_num_rows($result)  0) {
于 2013-09-18T20:39:36.897 回答