为什么这只有一部分有效?我在工作部分添加了评论:
session_start();
$_SESSION['views']=1;
$pageon="edited";
$button=" ";
$user=$_SESSION['username'];
$otoon = $_POST['otoon'];
$oserver = $_POST['oserver'];
$toonname = mysql_real_escape_string($_POST['toonname']);
$server = mysql_real_escape_string($_POST['server']);
$guild = mysql_real_escape_string($_POST['guild']);
echo $user . " " . $otoon . " " . $oserver . " " . $toonname . "<br />";
if (!empty($toonname)) {
$tql="UPDATE
reguserstest AS rt
INNER JOIN
alt_toon AS att
ON
att.`toonname` = rt.`toonname`
SET
rt.`toonname` = CASE WHEN rt.`username`='$user' AND rt.`server`='$oserver' AND rt.`toonname`='$otoon' THEN '$toonname'
ELSE rt.`toonname` END ,
att.`toonname` = CASE WHEN att.`username`='$user' AND att.`server`='$oserver' AND att.`toonname`='$otoon' THEN '$toonname'
ELSE att.`toonname` END
WHERE
( rt.`username`='$user' AND rt.`server`='$oserver' AND rt.`toonname`='$otoon' )
OR
( att.`username`='$user' AND att.`server`='$oserver' AND att.`toonname`='$otoon' )";
if (mysql_query($tql,$con))
{
echo "Toon name updated to: " . $toonname . "<br />";
} else {
echo "<h1>Error</h1>";
}
}
//BEGINNING OF THE WORKING CODE!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if (!empty($server)) {
$sql="UPDATE
reguserstest AS rt
INNER JOIN
alt_toon AS att
ON
att.`server` = rt.`server`
SET
rt.`server` = CASE WHEN rt.`username`='$user' AND rt.`server`='$oserver' AND rt.`toonname`='$otoon' THEN '$server'
ELSE rt.`server` END ,
att.`server` = CASE WHEN att.`username`='$user' AND att.`server`='$oserver' AND att.`toonname`='$otoon' THEN '$server'
ELSE att.`server` END
WHERE
( rt.`username`='$user' AND rt.`server`='$oserver' AND rt.`toonname`='$otoon' )
OR
( att.`username`='$user' AND att.`server`='$oserver' AND att.`toonname`='$otoon' )";
if (mysql_query($sql,$con))
{
echo "Server updated to: " . $server . "<br />";
} else {
mysql_error();
}
}
//THE WORKING CODE ENDS HERE ---- WHY??????
if (!empty($guild)) {
$gql="UPDATE
reguserstest AS rt
INNER JOIN
alt_toon AS att
ON
att.`guild` = rt.`guild`
SET
rt.`guild` = CASE WHEN rt.`username`='$user' AND rt.`server`='$oserver' AND rt.`toonname`='$otoon' THEN '$guild'
ELSE rt.`guild` END ,
att.`guild` = CASE WHEN att.`username`='$user' AND att.`server`='$oserver' AND att.`toonname`='$otoon' THEN '$guild'
ELSE att.`guild` END
WHERE
( rt.`username`='$user' AND rt.`server`='$oserver' AND rt.`toonname`='$otoon' )
OR
( att.`username`='$user' AND att.`server`='$oserver' AND att.`toonname`='$otoon' )";
if (mysql_query($gql,$con))
{
echo "Guild updated to: " . $guild . "<br />";
} else {
echo mysql_error();
}
}
正如我所说,我可以让 $server 100% 的时间更新。但 $toonname 和 $guild 不会更新。他们都去了“卡通名称/公会更新为:WHATEVER”,但他们实际上并没有写在桌子上。