私の問題は、php の mysql_query 関数を介して以下のクエリを実行しようとすると、何も実行されないことです (もちろん、このクエリ以外はすべて機能します)。クエリの最後に die(mysql_error()) を配置すると、単一のエラーではなく、白いページのみが表示されます。一方、mysql クライアントから直接実行しようとすると、SQL コードが機能します。正確に何が間違っているのかわかりません。これがSQLコードです。
-- Instructions:
-- Set the NPC Entry and stats you want it to have below.
SET
@NPC_ENTRY := ".$entry.", -- This is your NPC's Entry
@NPC_HEALTH := ".$health.", -- This is the health value you want your NPC to have.
@NPC_MANA := ".$mana.", -- This is the mana value you want your NPC to have.
@NPC_ARMOR := ".$armor."; -- This is the armor value you want your NPC to have.
-- DO NOT CHANGE ANYTHING BELOW, UNLESS YOU KNOW WHAT YOU ARE DOING.
-- Getting NPC datas:
SET
@NPC_CLASS := (SELECT `unit_class` FROM creature_template WHERE Entry = @NPC_ENTRY),
@NPC_LEVEL := ROUND(((SELECT `minlevel` FROM creature_template WHERE Entry = @NPC_ENTRY)+ (SELECT `maxlevel` FROM creature_template WHERE Entry = @NPC_ENTRY))/2, 0),
@EXP := (SELECT `exp` FROM creature_template WHERE Entry = @NPC_ENTRY);
-- Getting base HP from a HP column defined by exp.
SET
@GET_HP_COL :=
(SELECT CASE @EXP
WHEN 0 THEN (SELECT basehp0 FROM creature_classlevelstats WHERE `level` = @NPC_LEVEL and `class` = @NPC_CLASS)
WHEN 1 THEN (SELECT basehp1 FROM creature_classlevelstats WHERE `level` = @NPC_LEVEL and `class` = @NPC_CLASS)
WHEN 2 THEN (SELECT basehp2 FROM creature_classlevelstats WHERE `level` = @NPC_LEVEL and `class` = @NPC_CLASS)
END),
-- Getting base mana
@GET_MA_COL := (SELECT basemana FROM creature_classlevelstats WHERE `level` = @NPC_LEVEL and `class` = @NPC_CLASS),
-- Getting base armor
@GET_AR_COL := (SELECT basearmor FROM creature_classlevelstats WHERE `level` = @NPC_LEVEL and `class` = @NPC_CLASS);
-- Running the update with all the data collected:
UPDATE creature_template SET Health_mod = (@NPC_HEALTH/@GET_HP_COL), Mana_mod = (@NPC_MANA/@GET_MA_COL), Armor_mod = (@NPC_ARMOR/@GET_AR_COL) WHERE Entry = @NPC_ENTRY;
私の投稿に誤りがありましたら、お詫び申し上げます。英語は私の母国語ではありません。:(