sqlnoob Posted March 28, 2008 Share Posted March 28, 2008 this bit doesn't seem to work for me: $taxuser = $_COOKIE["person"]; $con = mysql_connect("localhost","shugonl","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("shugonl", $con); $receiptresult = mysql_query ("SELECT Wealth, SUM(Wealth) FROM provinces WHERE Owner = '$taxuser'"); $taxreceipt = mysql_fetch_assoc($receiptresult); echo "<BR>".$taxreceipt; Quote Link to comment Share on other sites More sharing options...
sqlnoob Posted March 28, 2008 Author Share Posted March 28, 2008 these are the tables I'm using to get the data from: <?php if ($con = @mysql_connect('localhost', 'shugonl', 'password')) { mysql_select_db('shugonl', $con); echo 'connected to the database'; } else { echo 'connection failed'; } mysql_select_db("shugonl", $con); $sqlpersons = "CREATE TABLE persons ( Password varchar( NOT NULL, Clan varchar(10) NOT NULL, Username varchar(20) NOT NULL, Coffer int( NOT NULL, Taxheight int(1) NOT NULL, Yari int(6) NOT NULL, Dachi int(5) NOT NULL, Yumi int(5) NOT NULL, Daisho int(5) NOT NULL, Teppo int(5) NOT NULL, Honjin int(2) NOT NULL, Taxyear int(2) NOT NULL, Attackp int(1) NOT NULL, Lastyear int(2) NOT NULL, Religion int(1) NOT NULL, Insurgent int(2) NOT NULL )"; mysql_query($sqlpersons,$con); $startday = idate("d"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Akita', 'unused', '0', '2', '0', '0', '0', '0', '0', '2', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Amako', 'unused', '0', '2', '0', '0', '0', '0', '0', '44', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Arima', 'unused', '0', '2', '0', '0', '0', '0', '0', '59', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Asakura', 'unused', '0', '2', '0', '0', '0', '0', '0', '18', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Chiba', 'unused', '0', '2', '0', '0', '0', '0', '0', '0', '14', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Chosokabe', 'unused', '0', '2', '0', '0', '0', '0', '0', '56', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Hatakeyama', 'unused', '0', '2', '0', '0', '0', '0', '0', '32', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Hatano', 'unused', '0', '2', '0', '0', '0', '0', '0', '49', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Hojo', 'unused', '0', '2', '0', '0', '0', '0', '0', '13', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Hosokawa', 'unused', '0', '2', '0', '0', '0', '0', '0', '33', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Imagawa', 'unused', '0', '2', '0', '0', '0', '0', '0', '17', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Ishida', 'unused', '0', '2', '0', '0', '0', '0', '0', '27', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Isshiki', 'unused', '0', '2', '0', '0', '0', '0', '0', '50', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Ito', 'unused', '0', '2', '0', '0', '0', '0', '0', '63', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Jinbo', 'unused', '0', '2', '0', '0', '0', '0', '0', '19', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Kikkawa', 'unused', '0', '2', '0', '0', '0', '0', '0', '43', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Kikuchi', 'unused', '0', '2', '0', '0', '0', '0', '0', '61', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Kono', 'unused', '0', '2', '0', '0', '0', '0', '0', '54', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Maeda', 'unused', '0', '2', '0', '0', '0', '0', '0', '22', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Matsudaira', 'unused', '0', '2', '0', '0', '0', '0', '0', '25', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Miyoshi', 'unused', '0', '2', '0', '0', '0', '0', '0', '53', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Mori', 'unused', '0', '2', '0', '0', '0', '0', '0', '37', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Nagao', 'unused', '0', '2', '0', '0', '0', '0', '0', '3', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Oda', 'unused', '0', '2', '0', '0', '0', '0', '0', '28', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Otomo', 'unused', '0', '2', '0', '0', '0', '0', '0', '57', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Ouchi', 'unused', '0', '2', '0', '0', '0', '0', '0', '46', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Shimazu', 'unused', '0', '2', '0', '0', '0', '0', '0', '65', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Shoni', 'unused', '0', '2', '0', '0', '0', '0', '0', '62', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Takeda', 'unused', '0', '2', '0', '0', '0', '0', '0', '9', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Uesugi', 'unused', '0', '2', '0', '0', '0', '0', '0', '11', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Urakami', 'unused', '0', '2', '0', '0', '0', '0', '0', '39', '$startday', '0', '$startday', '0', '0')"); mysql_query("INSERT INTO persons (Password, Clan, Username, Coffer, Taxheight, Yari, Dachi, Yumi, Daisho, Teppo, Honjin, Taxyear, Attackp, Lastyear, Religion, Insurgent) VALUES ('demo', 'Yamana', 'unused', '0', '2', '0', '0', '0', '0', '0', '42', '$startday', '0', '$startday', '0', '0')"); mysql_select_db("shugonl", $con); $sqlprov = "CREATE TABLE provinces ( Identifier int(2) NOT NULL, Province varchar(10) NOT NULL, Capital varchar(11) NOT NULL, Castle varchar(10) NOT NULL, Owner varchar(20) NOT NULL, Wealth int(4) NOT NULL, Region int(2) NOT NULL, Attitude int(2) NOT NULL, Machi varchar(7) NOT NULL )"; mysql_query($sqlprov,$con); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('1', 'Sado', 'Sado', 'none', 'neutral', '50', '1', '1', 'coastal')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('2', 'Dewa', 'Sakata', 'none', 'Akita', '430', '2', '1', 'coastal')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('3', 'Echigo', 'Niigata', 'none', 'Nagao', '451', '2', '1', 'coastal')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('4', 'Hitachi', 'Ishioka', 'none', 'neutral', '605', '2', '1', 'plain')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('5', 'Mutsu', 'Wakamutsu', 'none', 'neutral', '1520', '2', '1', 'coastal')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('6', 'Shimotsuke', 'Utsunomiya', 'none', 'neutral', '380', '2', '1', 'hilly')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('7', 'Awa', 'Tokushima', 'none', 'neutral', '177', '9', '1', 'coastal')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('8', 'Izu', 'Tagata', 'none', 'neutral', '89', '3', '1', 'forest')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('9', 'Kai', 'Kofu', 'none', 'Takeda', '207', '3', '1', 'hilly')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('10', 'Kazusa', 'Otaki', 'none', 'neutral', '96', '3', '1', 'coastal')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('11', 'Kozuke', 'Maebashi', 'none', 'Uesugi', '608', '3', '1', 'hilly')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('12', 'Musashi', 'Edo', 'none', 'neutral', '2557', '3', '1', 'plain')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('13', 'Sagami', 'Odawara', 'none', 'Hojo', '506', '3', '1', 'plain')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('14', 'Shimousa', 'Sakura', 'none', 'Chiba', '101', '3', '1', 'plain')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('15', 'Shinano', 'Matsumoto', 'none', 'neutral', '402', '3', '1', 'plain')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('16', 'Suruga', 'Sumpu', 'none', 'Imagawa', '245', '3', '1', 'forest')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('17', 'Totomi', 'Hamamatsu', 'none', 'Imagawa', '288', '3', '1', 'coastal')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('18', 'Echizen', 'Fukui', 'none', 'Asakura', '180', '4', '3', 'hilly')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('19', 'Etchu', 'Takaoka', 'none', 'Jinbo', '260', '4', '2', 'hilly')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('20', 'Hida', 'Takayama', 'none', 'neutral', '120', '4', '2', 'hilly')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('21', 'Kaga', 'Kanazawa', 'none', 'Maeda', '835', '4', '3', 'hilly')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('22', 'Noto', 'Nanao', 'none', 'Maeda', '215', '4', '2', 'coastal')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('23', 'Iga', 'Ueno', 'none', 'neutral', '95', '5', '3', 'hilly')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, machi) VALUES ('24', 'Ise', 'Suzuka', 'none', 'neutral', '440', '5', '3', 'forest')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('25', 'Mikawa', 'Okazaki', 'none', 'Matsudaira', '252', '5', '1', 'coastal')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('26', 'Mino', 'Gifu', 'none', 'Oda', '135', '5', '2', 'hilly')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('27', 'Omi', 'Odani', 'none', 'Ishida', '194', '5', '2', 'plain')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('28', 'Owari', 'Kiyosu', 'none', 'Oda', '200', '5', '1', 'plain')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('29', 'Shima', 'Toba', 'none', 'neutral', '51', '5', '1', 'forest')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('30', 'Izumi', 'Izumi', 'none', 'Hosokawa', '304', '6', '2', 'coastal')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('31', 'Kawachi', 'Fujidera', 'none', 'Hosokawa', '185', '6', '1', 'plain')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('32', 'Kii', 'Wakayama', 'none', 'Hatakeyama', '376', '6', '3', 'forest')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('33', 'Settsu', 'Osaka', 'none', 'Hosokawa', '459', '6', '3', 'plain')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('34', 'Yamashiro', 'Kyoto', 'none', 'neutral', '704', '6', '3', 'plain')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('35', 'Yamato', 'Nara', 'none', 'neutral', '200', '6', '3', 'hilly')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('36', 'Aki', 'Hiroshima', 'none', 'Mori', '800', '7', '2', 'coastal')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('37', 'Bingo', 'Fuchu', 'none', 'Mori', '130', '7', '2', 'forest')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('38', 'Bitchu', 'Soja', 'none', 'Hosokawa', '114', '7', '2', 'forest')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('39', 'Bizen', 'Okayama', 'none', 'Urakami', '574', '7', '1', 'coastal')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('40', 'Harima', 'Himeji', 'none', 'neutral', '220', '7', '3', 'forest')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('41', 'Hoki', 'Kurayoshi', 'none', 'neutral', '103', '7', '2', 'forest')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('42', 'Inaba', 'Tottori', 'none', 'Yamana', '125', '7', '2', 'forest')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('43', 'Iwami', 'Hamada', 'none', 'Kikkawa', '53', '7', '2', 'forest')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('44', 'Izumo', 'Matsue', 'none', 'Amako', '106', '7', '2', 'plain')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('45', 'Mimasaka', 'Tsuyama', 'none', 'Urakami', '68', '7', '2', 'hilly')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('46', 'Nagato', 'Shimonoseki', 'none', 'Ouchi', '236', '7', '1', 'coastal')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('47', 'Suwa', 'Hofu', 'none', 'Ouchi', '209', '7', '1', 'coastal')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('48', 'Tajima', 'Hidaka', 'none', 'Yamana', '60', '7', '1', 'forest')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('49', 'Tamba', 'Kameyama', 'none', 'Hatano', '81', '7', '1', 'forest')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('50', 'Tango', 'Maizuru', 'none', 'Isshiki', '208', '7', '1', 'coastal')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('51', 'Wakasa', 'Obama', 'none', 'neutral', '112', '7', '1', 'coastal')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('52', 'Awaji', 'Minami', 'none', 'neutral', '56', '8', '1', 'coastal')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('53', 'Awa', 'Miyoshi', 'none', 'Miyoshi', '90', '3', '2', 'coastal')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('54', 'Iyo', 'Matsuyama', 'none', 'Kono', '93', '9', '2', 'forest')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('55', 'Sanuki', 'Takamatsu', 'none', 'Miyoshi', '155', '9', '2', 'coastal')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('56', 'Tosa', 'Nankoku', 'none', 'Chosokabe', '222', '9', '3', 'hilly')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('57', 'Bungo', 'Kokokufu', 'none', 'Otomo', '125', '10', '1', 'coastal')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('58', 'Buzen', 'Fukuoka', 'none', 'neutral', '370', '10', '1', 'coastal')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('59', 'Chikugo', 'Kurume', 'none', 'Arima', '132', '10', '1', 'forest')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('60', 'Chikuzen', 'Dazaifu', 'none', 'neutral', '304', '10', '1', 'coastal')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('61', 'Higo', 'Kumamoto', 'none', 'Kikuchi', '225', '10', '2', 'hilly')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('62', 'Hizen', 'Yamato', 'none', 'Shoni', '1447', '10', '2', 'coastal')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('63', 'Hyuga', 'Saito', 'none', 'Ito', '107', '10', '2', 'coastal')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('64', 'Osumi', 'Kokubu', 'none', 'Shimazu', '121', '10', '1', 'hilly')"); mysql_query("INSERT INTO provinces (Identifier, Province, Capital, Castle, Owner, Wealth, Region, Attitude, Machi) VALUES ('65', 'Satsuma', 'Kagoshima', 'none', 'Shimazu', '605', '10', '1', 'forest')"); ?> (edited by kenrbnsn to add tags) Quote Link to comment Share on other sites More sharing options...
sqlnoob Posted March 28, 2008 Author Share Posted March 28, 2008 Is anyone able to help me and see what's wrong with it. Any help is much appreciated Quote Link to comment Share on other sites More sharing options...
ansarka Posted March 28, 2008 Share Posted March 28, 2008 change the query to $receiptresult = mysql_query ("SELECT SUM(Wealth) FROM provinces WHERE Owner = '$taxuser'"); Quote Link to comment Share on other sites More sharing options...
sqlnoob Posted March 28, 2008 Author Share Posted March 28, 2008 Fatal error: Unsupported operand types in www/economy.php on line 84 Quote Link to comment Share on other sites More sharing options...
sqlnoob Posted March 28, 2008 Author Share Posted March 28, 2008 line 84 is this line: errrr $receiptresult = mysql_query ("SELECT SUM(Wealth) FROM provinces WHERE Owner = '$taxuser'"); Quote Link to comment Share on other sites More sharing options...
sqlnoob Posted March 28, 2008 Author Share Posted March 28, 2008 changed it to this. Now it no longer returns an fatal error, but it still doesn't echo my result, nor updates it the way it supposed. $receiptresult = mysql_query ("SELECT SUM(Wealth) FROM provinces GROUP BY Owner WHERE Owner = '$taxuser'"); $taxrowreceipt = mysql_fetch_assoc($receiptresult); $taxreceipt = $taxrowreceipt['SUM(wealth)']; why? Quote Link to comment Share on other sites More sharing options...
xyn Posted March 28, 2008 Share Posted March 28, 2008 try: $sql =mysql_query("select sum(`Wealth`) from `provinces` where `Owner` ='$taxuser' group by `Owner`"); $result =mysql_fetch_array($sql); $amount =$result[0]; Quote Link to comment Share on other sites More sharing options...
sqlnoob Posted March 28, 2008 Author Share Posted March 28, 2008 tried it and nope still doesn't work this turned out to be more difficult then expected Quote Link to comment Share on other sites More sharing options...
xyn Posted March 28, 2008 Share Posted March 28, 2008 Explain what you are trying to do? and only post the main chunk of code... so i can be bothered to read it all. Quote Link to comment Share on other sites More sharing options...
sqlnoob Posted March 28, 2008 Author Share Posted March 28, 2008 ok I want to do something like this: http://www.w3schools.com/sql/sql_groupby.asp In my case I want to have the SUM of all wealth of a certain clan whichever is logged in. I get the clan name from the cookie, which I use to search the table called provinces to get all the provinces Wealth of this clan. I want the user/clan to be able tax the wealth of all the provinces they own. So lets say Hosokawa is logged in at the moment, then I need to fetch the SUM of all their Wealth of the provinces they own. In this example Hosokawa owns the provinces Izumi, Kawachi and Settsu, which respectively should get Hosokawa 304 + 185 + 459 = a SUM of 948. I'm new at this and I haven't used aggregate functions before, so clearly I'm doing something wrong, but what? ??? Quote Link to comment Share on other sites More sharing options...
sqlnoob Posted March 28, 2008 Author Share Posted March 28, 2008 it is this SUM that I don't get, neither in the echo, nor in my updating part of my economy.php file. So that means it somehow is not fetching it, but what exactly am I doing wrong there. I can't seem to figure that out. Quote Link to comment Share on other sites More sharing options...
ansarka Posted March 28, 2008 Share Posted March 28, 2008 r u sure you have value in $taxuser Quote Link to comment Share on other sites More sharing options...
sqlnoob Posted March 28, 2008 Author Share Posted March 28, 2008 I should have, but let me echo it, just to be sure Quote Link to comment Share on other sites More sharing options...
sqlnoob Posted March 28, 2008 Author Share Posted March 28, 2008 yup 100% sure I have a value there, it echoes the clans name, so that's allright. either the way I'm querying it, or the way I'm fetching it, or the table is wrong somehow. ??? Quote Link to comment Share on other sites More sharing options...
ansarka Posted March 28, 2008 Share Posted March 28, 2008 change your code to print the sql check weather the sql is correct or not copy the sql and try it directly in mysql $sql ="select sum(Wealth) as sumofwealth from provinces where Owner ='$taxuser' group by Owner"; echo "$sql"; $query=mysql_query($sql); $result =mysql_fetch_array($query); $amount =$result[sumofwealth]; Quote Link to comment Share on other sites More sharing options...
sqlnoob Posted March 28, 2008 Author Share Posted March 28, 2008 now this is the echo i get: select sum(Wealth) as sumofwealth FROM provinces WHERE Owner ='Kikkawa' GROUP BY Owner taxes have been collected still no SUM ??? Quote Link to comment Share on other sites More sharing options...
sqlnoob Posted March 28, 2008 Author Share Posted March 28, 2008 oh shoot forgot to change that reference thanks alot all, it works now Thread closed! Quote Link to comment 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.