while($x < 10)
{
$str = "( NULL, '{$players[$x]}', '1' , 0 + {$sonucs[$x]},oynananoyun - win,'{$rols[$x]}','{$teams[$x]}','{$playerkills[$x]}','{$playerdeaths[$x]}','{$playerassists[$x]}','{$creeps[$x]}','{$dmgs[$x]}','{$dpms[$x]}','{$wards[$x]}','{$playergolds[$x]}','{$gpms[$x]}', '{$goldpercantages[$x]}', 0 + {$fbs[$x]},'{$dmgpercantages[$x]}', '{$wardscleared[$x]}', '{$wpm[$x]}', '{$wcpm[$x]}','{$wardpercents[$x]}', '{$wardsclearedpercents[$x]}', '{$cspms[$x]}')";
$yaya = "kill = kill + {$playerkills[$x]}, death = death + {$playerdeaths[$x]},assist = assist + {$playerassists[$x]},cs = cs + {$creeps[$x]}, cspm = cspm + {$cspms[$x]}, takim = {$teams[$x]}, dmg = dmg + {$dmgs[$x]}, dpm = dpm + {$dpms[$x]},wardplaced = wardplaced + {$wards[$x]}, oynananoyun = oynananoyun + 1, win = win + {$sonucs[$x]}, rol = {$rols[$x]}, gold = gold + {$playergolds[$x]}, goldshare = goldshare + {$goldpercantages[$x]}, gpm = gpm + {$gpms[$x]}, fb = fb + {$fbs[$x]}, dmgshare = dmgshare + {$dmgpercantages[$x]}, wardcleared = wardcleared + {$wardscleared[$x]}, wardplacedpm = wardplacedpm + {$wpm[$x]}, wardclearedpm = wardclearedpm + {$wcpm[$x]}, wardplacedshare = wardplacedshare + {$wardpercents[$x]}, wardclearedshare = wardclearedshare + {$wardsclearedpercents[$x]}";
mysql_query ("INSERT INTO playerstats18 (`id`,`player`,`oynananoyun`,`win`,`lose`,`rol`,`takim`,`kill`,`death`,`assist`,`cs`,`dmg`,`dpm`,`wardplaced`,`gold`,`goldshare`,`gpm`,`fb`,`dmgshare`,`wardcleared`,`wardplacedpm`,`wardclearedpm`,`wardplacedshare`,`wardclearedshare`,`cspm`) VALUES $str ON DUPLICATE KEY UPDATE $yaya");
$x++;
}
mysql_query正在运行,但后来我在$ yaya添加了更多的值,现在它还没有运行。我没有遗漏任何逗号,我查了一下。它没有更新或插入。
“您的SQL语法有错误;请查看与您的MySQL服务器版本对应的手册,以便在'kill = kill + 0,death = death + 1,assist = assist + 14,cs附近使用正确的语法= cs + 28,cspm = csp'在第1行“
'kill = kill + 0,death = death + 1,assist = assist + 14,cs = cs + 28,cspm = csp'在第1行
$ yaya喜欢什么
kill = kill + 0, death = death + 1,assist = assist + 14,
cs = cs + 28, cspm = cspm + 1, takim = DP,
dmg = dmg + 3.0, dpm = dpm + 110,wardplaced = wardplaced + 43,
oynananoyun = oynananoyun + 1, win = win + 1 , rol = Support,
gold = gold + 7.7b, goldshare = goldshare + 14.1,
gpm = gpm + 283, fb = fb + 0,
dmgshare = dmgshare + 6.4, wardcleared = wardcleared + 9,
wardplacedpm = wardplacedpm + 1.58,
wardclearedpm = wardclearedpm + 0.33,
wardplacedshare = wardplacedshare + 29.6,
wardclearedshare = wardclearedshare + 31
编辑:我将yaya字符串更改为
$yaya = "`kill` = `kill` + {$playerkills[$x]},
death = death + {$playerdeaths[$x]},
assist = assist + {$playerassists[$x]},
cs = cs + {$creeps[$x]},
cspm = cspm + {$cspms[$x]},
takim = '{$teams[$x]}',
dmg = dmg + {$dmgs[$x]},
dpm = dpm + {$dpms[$x]},
wardplaced = wardplaced + {$wards[$x]},
oynananoyun = oynananoyun + 1,
win = win + {$sonucs[$x]},
rol = '{$rols[$x]}',
gold = gold + '{$playergolds[$x]}',
goldshare = goldshare + {$goldpercantages[$x]},
gpm = gpm + {$gpms[$x]}, fb = fb + {$fbs[$x]},
dmgshare = dmgshare + {$dmgpercantages[$x]},
wardcleared = wardcleared + {$wardscleared[$x]},
wardplacedpm = wardplacedpm + {$wpm[$x]},
wardclearedpm = wardclearedpm + {$wcpm[$x]},
wardplacedshare = wardplacedshare + {$wardpercents[$x]},
wardclearedshare = wardclearedshare + {$wardsclearedpercents[$x]}";
我将杀戮改为kill
,
{$ playergolds [$ x]}到'{$ playergolds [$ x]}',因为它有“b”(例如6.6b)
和引用的varchars(不确定是否有必要)。
答案 0 :(得分:1)
由于rol
是VARCHAR
,因此您需要在值周围加上引号。
rol = {$rols[$x]}
应该是:
rol = '{$rols[$x]}'
您可以在$yaya
:
rol = Support
应该是
rol = 'Support'
如果您使用PDO或mysqli准备好的查询,则不会出现这样的问题。
另一个问题是kill
是保留字。要将其用作列名,您需要使用反引号来转义它:
`kill` = `kill` + {$playerkills[$x]}
此外,使用ON DUPLICATE KEY UPDATE
时,您无需重复VALUES
列表中的所有值。你可以写
rol = VALUES(rol)
表示更新应使用与没有重复键时插入的值相同的值。所以你可以写:
$yaya = "`kill` = `kill` + VALUES(`kill`), death = death + VALUES(death), assist = assist + VALUES(assist),
cs = cs + VALUES(cs), cspm = cspm + VALUES(cspm), takim = VALUES(takim), dmg = dmg + VALUES(dmg),
dpm = dpm + VALUES(dpm), wardplaced = wardplaced + VALUES(wardplaced),
oynananoyun = oynananoyun + 1, win = win + VALUES(win), rol = VALUES(rol),
gold = gold + VALUES(gold), goldshare = goldshare + VALUES(goldshare), gpm = gpm + VALUES(gpm),
fb = fb + VALUES(fb), dmgshare = dmgshare + VALUES(dmgshare), wardcleared = wardcleared + VALUES(wardcleard),
wardplacedpm = wardplacedpm + VALUES(wardplacedpm), wardclearedpm = wardclearedpm + VALUES(wardclearedpm),
wardplacedshare = wardplacedshare + VALUES(wardplacedshare), wardclearedshare = wardclearedshare + VALUES(wardclearedshare)";