drisate Posted April 18, 2008 Share Posted April 18, 2008 Hey guys i made a PHP loop script to make an update on a very very very big database ... The script is supose to remake entry id's bigger then 190000 but the it is used un more then one table so i had to The table looks like this [code=php:0]CREATE TABLE /*!32312 IF NOT EXISTS*/ "items" ( "entry" int(10) NOT NULL DEFAULT '0', "class" int(10) NOT NULL DEFAULT '0', "subclass" int(10) NOT NULL DEFAULT '0', "field4" int(10) NOT NULL DEFAULT '-1', "name1" varchar(255) NOT NULL DEFAULT '', "name2" varchar(255) NOT NULL DEFAULT '', "name3" varchar(255) NOT NULL DEFAULT '', "name4" varchar(255) NOT NULL DEFAULT '', "displayid" int(10) NOT NULL DEFAULT '0', "quality" int(10) NOT NULL DEFAULT '0', "flags" int(10) NOT NULL DEFAULT '0', "buyprice" int(10) NOT NULL DEFAULT '0', "sellprice" int(10) NOT NULL DEFAULT '0', "inventorytype" int(10) NOT NULL DEFAULT '0', "allowableclass" int(10) NOT NULL DEFAULT '-1', "allowablerace" int(10) NOT NULL DEFAULT '-1', "itemlevel" int(10) NOT NULL DEFAULT '0', "requiredlevel" int(10) NOT NULL DEFAULT '0', "RequiredSkill" int(10) NOT NULL DEFAULT '0', "RequiredSkillRank" int(10) NOT NULL DEFAULT '0', "RequiredSkillSubRank" int(10) NOT NULL DEFAULT '0', "RequiredPlayerRank1" int(10) NOT NULL DEFAULT '0', "RequiredPlayerRank2" int(10) NOT NULL DEFAULT '0', "RequiredFaction" int(10) NOT NULL DEFAULT '0', "RequiredFactionStanding" int(10) NOT NULL DEFAULT '0', "Unique" int(10) NOT NULL DEFAULT '0', "maxcount" int(10) NOT NULL DEFAULT '0', "ContainerSlots" int(10) NOT NULL DEFAULT '0', "stat_type1" int(10) NOT NULL DEFAULT '0', "stat_value1" int(11) NOT NULL DEFAULT '0', "stat_type2" int(10) NOT NULL DEFAULT '0', "stat_value2" int(11) NOT NULL DEFAULT '0', "stat_type3" int(10) NOT NULL DEFAULT '0', "stat_value3" int(11) NOT NULL DEFAULT '0', "stat_type4" int(10) NOT NULL DEFAULT '0', "stat_value4" int(11) NOT NULL DEFAULT '0', "stat_type5" int(10) NOT NULL DEFAULT '0', "stat_value5" int(11) NOT NULL DEFAULT '0', "stat_type6" int(10) NOT NULL DEFAULT '0', "stat_value6" int(11) NOT NULL DEFAULT '0', "stat_type7" int(10) NOT NULL DEFAULT '0', "stat_value7" int(11) NOT NULL DEFAULT '0', "stat_type8" int(10) NOT NULL DEFAULT '0', "stat_value8" int(11) NOT NULL DEFAULT '0', "stat_type9" int(10) NOT NULL DEFAULT '0', "stat_value9" int(11) NOT NULL DEFAULT '0', "stat_type10" int(10) NOT NULL DEFAULT '0', "stat_value10" int(11) NOT NULL DEFAULT '0', "dmg_min1" float NOT NULL DEFAULT '0', "dmg_max1" float NOT NULL DEFAULT '0', "dmg_type1" int(10) NOT NULL DEFAULT '0', "dmg_min2" float NOT NULL DEFAULT '0', "dmg_max2" float NOT NULL DEFAULT '0', "dmg_type2" int(10) NOT NULL DEFAULT '0', "dmg_min3" float NOT NULL DEFAULT '0', "dmg_max3" float NOT NULL DEFAULT '0', "dmg_type3" int(10) NOT NULL DEFAULT '0', "dmg_min4" float NOT NULL DEFAULT '0', "dmg_max4" float NOT NULL DEFAULT '0', "dmg_type4" int(10) NOT NULL DEFAULT '0', "dmg_min5" float NOT NULL DEFAULT '0', "dmg_max5" float NOT NULL DEFAULT '0', "dmg_type5" int(10) NOT NULL DEFAULT '0', "armor" int(10) NOT NULL DEFAULT '0', "holy_res" int(10) NOT NULL DEFAULT '0', "fire_res" int(10) NOT NULL DEFAULT '0', "nature_res" int(10) NOT NULL DEFAULT '0', "frost_res" int(10) NOT NULL DEFAULT '0', "shadow_res" int(10) NOT NULL DEFAULT '0', "arcane_res" int(10) NOT NULL DEFAULT '0', "delay" int(10) NOT NULL DEFAULT '0', "ammo_type" int(10) NOT NULL DEFAULT '0', "range" float NOT NULL DEFAULT '0', "spellid_1" int(10) NOT NULL DEFAULT '0', "spelltrigger_1" int(10) NOT NULL DEFAULT '0', "spellcharges_1" int(11) NOT NULL DEFAULT '0', "spellcooldown_1" int(11) NOT NULL DEFAULT '0', "spellcategory_1" int(10) NOT NULL DEFAULT '0', "spellcategorycooldown_1" int(11) NOT NULL DEFAULT '0', "spellid_2" int(10) NOT NULL DEFAULT '0', "spelltrigger_2" int(10) NOT NULL DEFAULT '0', "spellcharges_2" int(11) NOT NULL DEFAULT '0', "spellcooldown_2" int(11) NOT NULL DEFAULT '0', "spellcategory_2" int(10) NOT NULL DEFAULT '0', "spellcategorycooldown_2" int(11) NOT NULL DEFAULT '0', "spellid_3" int(10) NOT NULL DEFAULT '0', "spelltrigger_3" int(10) NOT NULL DEFAULT '0', "spellcharges_3" int(11) NOT NULL DEFAULT '0', "spellcooldown_3" int(11) NOT NULL DEFAULT '0', "spellcategory_3" int(10) NOT NULL DEFAULT '0', "spellcategorycooldown_3" int(11) NOT NULL DEFAULT '0', "spellid_4" int(10) NOT NULL DEFAULT '0', "spelltrigger_4" int(10) NOT NULL DEFAULT '0', "spellcharges_4" int(11) NOT NULL DEFAULT '0', "spellcooldown_4" int(11) NOT NULL DEFAULT '0', "spellcategory_4" int(10) NOT NULL DEFAULT '0', "spellcategorycooldown_4" int(11) NOT NULL DEFAULT '0', "spellid_5" int(10) NOT NULL DEFAULT '0', "spelltrigger_5" int(10) NOT NULL DEFAULT '0', "spellcharges_5" int(11) NOT NULL DEFAULT '0', "spellcooldown_5" int(11) NOT NULL DEFAULT '0', "spellcategory_5" int(10) NOT NULL DEFAULT '0', "spellcategorycooldown_5" int(11) NOT NULL DEFAULT '0', "bonding" int(10) NOT NULL DEFAULT '0', "description" varchar(255) NOT NULL DEFAULT '', "page_id" int(10) NOT NULL DEFAULT '0', "page_language" int(10) NOT NULL DEFAULT '0', "page_material" int(10) NOT NULL DEFAULT '0', "quest_id" int(10) NOT NULL DEFAULT '0', "lock_id" int(10) NOT NULL DEFAULT '0', "lock_material" int(10) NOT NULL DEFAULT '-1', "sheathID" int(10) NOT NULL DEFAULT '0', "randomprop" int(30) NOT NULL DEFAULT '0', "unk203_1" int(10) NOT NULL DEFAULT '0', "block" int(10) NOT NULL DEFAULT '0', "itemset" int(10) NOT NULL DEFAULT '0', "MaxDurability" int(10) NOT NULL DEFAULT '0', "ZoneNameID" int(10) NOT NULL DEFAULT '0', "mapid" int(10) NOT NULL DEFAULT '0', "bagfamily" int(10) NOT NULL DEFAULT '0', "TotemCategory" int(10) NOT NULL DEFAULT '0', "socket_color_1" int(10) NOT NULL DEFAULT '0', "unk201_3" int(10) NOT NULL DEFAULT '0', "socket_color_2" int(10) NOT NULL DEFAULT '0', "unk201_5" int(10) NOT NULL DEFAULT '0', "socket_color_3" int(10) NOT NULL DEFAULT '0', "unk201_7" int(10) NOT NULL DEFAULT '0', "socket_bonus" int(10) NOT NULL DEFAULT '0', "GemProperties" int(10) NOT NULL DEFAULT '0', "ItemExtendedCost" int(10) NOT NULL DEFAULT '0', "ArenaRankRequirement" int(30) NOT NULL DEFAULT '0', "ReqDisenchantSkill" int(10) NOT NULL DEFAULT '0', "unk2" int(10) NOT NULL DEFAULT '0', PRIMARY KEY ("entry") ) /*!40100 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci*/; [/code] and my php script looks like this [code=php:0]<?php /** * @author Beaster * @Script Remake items id's */ $dbh2=mysql_connect("localhost", "user", "pass") or die ('1 Erreur: '.mysql_error()); mysql_select_db("ascent"); $start='190000'; // Evrything above this will get new id's $loop=1; echo "<center><h1>Starting</h1></center><br><br>"; $check = mysql_query("SELECT * FROM `items` WHERE entry>='$start' order by entry asc") or die (mysql_error()); while ($items = mysql_fetch_array($check)) { if ($loop=="1"){$last=$start;}else{$last++;} $update = mysql_query("UPDATE items SET entry='$last' where entry='$items[entry]'") or die (mysql_error()); $update = mysql_query("UPDATE playeritems SET entry='$last' where entry='$items[entry]'") or die (mysql_error()); $update = mysql_query("UPDATE vendors SET item='$last' where item='$items[entry]'") or die (mysql_error()); $update = mysql_query("UPDATE quests SET ReqItemId1='$last' where ReqItemId1='$items[entry]'") or die (mysql_error()); $update = mysql_query("UPDATE quests SET ReqItemId2='$last' where ReqItemId2='$items[entry]'") or die (mysql_error()); $update = mysql_query("UPDATE quests SET ReqItemId3='$last' where ReqItemId3='$items[entry]'") or die (mysql_error()); $update = mysql_query("UPDATE quests SET ReqItemId4='$last' where ReqItemId4='$items[entry]'") or die (mysql_error()); $update = mysql_query("UPDATE quests SET RewChoiceItemId1='$last' where RewChoiceItemId1='$items[entry]'") or die (mysql_error()); $update = mysql_query("UPDATE quests SET RewChoiceItemId2='$last' where RewChoiceItemId2='$items[entry]'") or die (mysql_error()); $update = mysql_query("UPDATE quests SET RewChoiceItemId3='$last' where RewChoiceItemId3='$items[entry]'") or die (mysql_error()); $update = mysql_query("UPDATE quests SET RewChoiceItemId4='$last' where RewChoiceItemId4='$items[entry]'") or die (mysql_error()); $update = mysql_query("UPDATE quests SET RewChoiceItemId5='$last' where RewChoiceItemId5='$items[entry]'") or die (mysql_error()); $update = mysql_query("UPDATE quests SET RewChoiceItemId6='$last' where RewChoiceItemId6='$items[entry]'") or die (mysql_error()); $update = mysql_query("UPDATE quests SET RewItemId1='$last' where RewItemId1='$items[entry]'") or die (mysql_error()); $update = mysql_query("UPDATE quests SET RewItemId2='$last' where RewItemId2='$items[entry]'") or die (mysql_error()); $update = mysql_query("UPDATE quests SET RewItemId3='$last' where RewItemId3='$items[entry]'") or die (mysql_error()); $update = mysql_query("UPDATE quests SET RewItemId4='$last' where RewItemId4='$items[entry]'") or die (mysql_error()); echo "Item $items[entry] is now $last<br>"; $loop++; } echo "<br><br><center><h1>End</h1></center>"; ?> [/code] But for some reason the page is not loading at all ... not even the echo "<center><h1>Starting</h1></center><br><br>"; part ... it's not the first time i build a loop script for a big database ... but it's the first time i get this problem. Is there a way to do all this into one super SQL query i could execute? Quote Link to comment https://forums.phpfreaks.com/topic/101651-weird-bug/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.