为什么Index会在MySQL Update行中导致错误?删除它使查询工作。
错误是
MySQLi无法查询:UPDATE任务SET id ='1',FactionID ='2',ReqReputation ='2',ReqClassID ='3',ReqClassPoints ='2',Name ='2',Description =' 2',EndText ='2',经验='2',GExperience ='2',铜='2',银='2',黄金='2',硬币='2',信誉='2' ,ClassPoints ='2',RewardType ='S',Level ='2',Upgrade ='1',Once ='1',Slot ='2',Value ='2',Field ='2',Index ='2',徽章='3',公会='1',GiveMembership ='0',战争='1'WHERE id = 1 - 2016年12月20日,上午1:58
$id = $_POST["Id"];
$FactionID = $_POST["Faction"];
$ReqReputation = $_POST["RequiredReputation"];
$ReqClassID = $_POST["Class"];
$ReqClassPoints = $_POST["ReqClassRank"];
$Name = $_POST["Name"];
$Description = $_POST["Description"];
$EndText = $_POST["EndText"];
$Experience = $_POST["Experience"];
$GExperience = $_POST["GuildExperience"];
$Copper = $_POST["Copper"];
$Silver = $_POST["Silver"];
$Gold = $_POST["Gold"];
$Coins = $_POST["Diamond"];
$Reputation = $_POST["Reputation"];
$ClassPoints = $_POST["ClassPoints"];
$RewardType = $_POST["RewardType"];
$Level = $_POST["Level"];
$Upgrade = $_POST["Upgrade"];
$Once = $_POST["Once"];
$Slot = $_POST["Slot"];
$Value = $_POST["Value"];
$Field = $_POST["Field"];
$QIndex = $_POST["Index"];
$Badges = $_POST["Badges"];
$Guild = $_POST["Guild"];
$GiveMembership = $_POST["GiveMembership"];
$War = $_POST["War"];
$MYSQL_QUERY = $content->DBase('Query', array( 0 => "UPDATE quests SET id = '$id', FactionID = '$FactionID', ReqReputation = '$ReqReputation', ReqClassID = '$ReqClassID', ReqClassPoints = '$ReqClassPoints', Name = '$Name', Description = '$Description', EndText = '$EndText', Experience = '$Experience', GExperience = '$GExperience', Copper = '$Copper', Silver = '$Silver', Gold = '$Gold', Coins = '$Coins', Reputation = '$Reputation', ClassPoints = '$ClassPoints', RewardType = '$RewardType', Level = '$Level', Upgrade = '$Upgrade', Once = '$Once', Slot = '$Slot', Value = '$Value', Field = '$Field', Index = '$Index', Badges = '$Badges', Guild = '$Guild', GiveMembership = '$GiveMembership', War = '$War' WHERE id = $id"));
功能DBase
/** MYSQL IMPROVED EXTENSION (PARENT CLASS) **/
public function DBase($type, $params = array()) {
if (!$this->SITE->CMS->Connection)
SystemExit('No available MySQLi connection', __LINE__, __FILE__);
switch (strtoupper($type)) {
case 'QUERY':
if ($Query = parent::query($params[0])) {
$this->SITE->CMS->TotalQuery++;
return $Query;
} else
SystemExit('MySQLi failed to query: ' . $params[0], __LINE__, __FILE__);
break;
case 'PREPARE':
if ($Query = parent::prepare($params[0])) {
$this->SITE->CMS->TotalQuery++;
return $Query;
} else
SystemExit('MySQLi failed to prepare: ' . $params[0], __LINE__, __FILE__);
break;
case 'ESCAPESTRING':
if ($Escape = parent::real_escape_string($params[0]))
return $Escape;
else
SystemExit('MySQLi failed to escape: ' . $params[0], __LINE__, __FILE__);
break;
}
}
答案 0 :(得分:1)
您使用错误的变量作为索引。您在上面将其定义为$ QIndex,但在最后一行将其称为$ Index。请尝试以下方法:
$id = $_POST["Id"];
$FactionID = $_POST["Faction"];
$ReqReputation = $_POST["RequiredReputation"];
$ReqClassID = $_POST["Class"];
$ReqClassPoints = $_POST["ReqClassRank"];
$Name = $_POST["Name"];
$Description = $_POST["Description"];
$EndText = $_POST["EndText"];
$Experience = $_POST["Experience"];
$GExperience = $_POST["GuildExperience"];
$Copper = $_POST["Copper"];
$Silver = $_POST["Silver"];
$Gold = $_POST["Gold"];
$Coins = $_POST["Diamond"];
$Reputation = $_POST["Reputation"];
$ClassPoints = $_POST["ClassPoints"];
$RewardType = $_POST["RewardType"];
$Level = $_POST["Level"];
$Upgrade = $_POST["Upgrade"];
$Once = $_POST["Once"];
$Slot = $_POST["Slot"];
$Value = $_POST["Value"];
$Field = $_POST["Field"];
$QIndex = $_POST["Index"];
$Badges = $_POST["Badges"];
$Guild = $_POST["Guild"];
$GiveMembership = $_POST["GiveMembership"];
$War = $_POST["War"];
$MYSQL_QUERY = $content->DBase('Query', array( 0 => "UPDATE quests SET id = '$id', FactionID = '$FactionID', ReqReputation = '$ReqReputation', ReqClassID = '$ReqClassID', ReqClassPoints = '$ReqClassPoints', Name = '$Name', Description = '$Description', EndText = '$EndText', Experience = '$Experience', GExperience = '$GExperience', Copper = '$Copper', Silver = '$Silver', Gold = '$Gold', Coins = '$Coins', Reputation = '$Reputation', ClassPoints = '$ClassPoints', RewardType = '$RewardType', Level = '$Level', Upgrade = '$Upgrade', Once = '$Once', Slot = '$Slot', Value = '$Value', Field = '$Field', Index = '$QIndex', Badges = '$Badges', Guild = '$Guild', GiveMembership = '$GiveMembership', War = '$War' WHERE id = $id"));
另见@Rahul的评论。你的:“WHERE id ='$ id'”似乎传递了错误的值。 ID很可能不是日期/时间的版本。如果您想使用当前日期+时间,我们可以使用类似NOW()的内容。它会将当前日期和时间缩短到第二个。