Jump to content

help with this code...


seany123

Recommended Posts

firstly ill give all the information... then explain what im trying to do and whats wrong:

 

-- phpMyAdmin SQL Dump

-- version 3.2.0.1

-- http://www.phpmyadmin.net

--

-- Host: localhost

-- Generation Time: Nov 11, 2009 at 05:44 PM

-- Server version: 5.1.37

-- PHP Version: 5.3.0

 

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

 

--

-- Database: `maf10000_db1`

--

 

-- --------------------------------------------------------

 

--

-- Table structure for table `blueprint_items`

--

 

CREATE TABLE IF NOT EXISTS `blueprint_items` (

  `id` int(11) NOT NULL AUTO_INCREMENT,

  `name` varchar(255) COLLATE latin1_general_ci NOT NULL DEFAULT '',

  `description` text COLLATE latin1_general_ci NOT NULL,

  `type` enum('weapon','armour','shoe','consumable','pet','rare','parts','other') COLLATE latin1_general_ci NOT NULL DEFAULT 'weapon',

  `value` int(11) NOT NULL DEFAULT '0',

  `shopcost` int(11) NOT NULL DEFAULT '0',

  `strengthbonus` int(11) NOT NULL DEFAULT '0',

  `defensebonus` int(11) NOT NULL DEFAULT '0',

  `speedbonus` int(11) NOT NULL DEFAULT '0',

  `powerbonus` int(11) NOT NULL DEFAULT '0',

  `torquebonus` int(11) NOT NULL DEFAULT '0',

  `weightbonus` int(11) NOT NULL DEFAULT '0',

  `img` varchar(255) COLLATE latin1_general_ci NOT NULL,

  `features` varchar(255) COLLATE latin1_general_ci NOT NULL,

  PRIMARY KEY (`id`)

) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=96 ;

 

--

-- Dumping data for table `blueprint_items`

--

 

INSERT INTO `blueprint_items` (`id`, `name`, `description`, `type`, `value`, `shopcost`, `strengthbonus`, `defensebonus`, `speedbonus`, `powerbonus`, `torquebonus`, `weightbonus`, `img`, `features`) VALUES

(1, 'Awake Pill', 'An item that restores your awake when used.', 'consumable', 0, 0, 0, 0, 0, 0, 0, 0, 'http://mafiakillerz.co.cc/img/items/1.jpg', '- refill awake 100% '),

(2, 'Hammer', 'A weapon used to attack other mobsters.', 'weapon', 1000, 1500, 3, 0, 0, 0, 0, 0, 'http://mafiakillerz.co.cc/img/items/2.jpg', '- Strength bonus 3%'),

(3, 'Baseball Bat', 'A weapon used to attack other mobsters.', 'weapon', 2000, 3000, 5, 0, 0, 0, 0, 0, 'http://mafiakillerz.co.cc/img/items/3.jpg', '- Strength bonus 5%'),

(4, 'Crow Bar', 'A weapon used to attack other mobsters.', 'weapon', 10000, 15000, 10, 0, 0, 0, 0, 0, 'http://mafiakillerz.co.cc/img/items/4.jpg', '- Strength bonus 10%'),

(5, 'Kitchen Knife', 'A weapon used to attack other mobsters.', 'weapon', 20000, 30000, 15, 0, 0, 0, 0, 0, 'http://mafiakillerz.co.cc/img/items/5.jpg', '- Stength bonus 15%'),

(6, 'Axe', 'A weapon used to attack other mobsters.', 'weapon', 160000, 240000, 25, 0, 0, 0, 0, 0, '', '- Stength bonus 25%'),

(7, 'Chainsaw', 'A weapon used to attack other mobsters.', 'weapon', 320000, 480000, 35, 0, 0, 0, 0, 0, '', '- Stength bonus 35%'),

(8, 'Rags', 'Armour used to defend yourself from other mobster attacks.', 'armour', 1000, 1500, 0, 3, 0, 0, 0, 0, '', '- Defense bonus 3%'),

(9, 'Padded Shirt', 'A piece of armour used to defend yourself from other citizen attacks.', 'armour', 2000, 3000, 0, 5, 0, 0, 0, 0, '', '- Defense bonus 5%'),

(10, 'Leather Vest', 'A piece of armour used to defend yourself from other citizen attacks.', 'armour', 10000, 15000, 0, 10, 0, 0, 0, 0, '', '- Defense bonus 10%'),

(11, 'Chainmail', 'A piece of armour used to defend yourself from other citizen attacks.', 'armour', 20000, 30000, 0, 15, 0, 0, 0, 0, '', '- Defense bonus 15%'),

(12, 'Platebody', 'A piece of armour used to defend yourself from other citizen attacks.', 'armour', 160000, 240000, 0, 25, 0, 0, 0, 0, '', '- Defense bonus 25%'),

(13, 'Bullet Proof Vest', 'A piece of armour used to defend yourself from other citizen attacks.', 'armour', 320000, 480000, 0, 35, 0, 0, 0, 0, '', '- Defense bonus 35%'),

(14, 'Meat Cleaver', 'A weapon used to attack other mobsters.', 'weapon', 100000, 160000, 20, 0, 0, 0, 0, 0, '', '- Strength bonus 20%'),

(15, 'Sledgehammer', 'A weapon used to attack other mobsters.', 'weapon', 240000, 360000, 30, 0, 0, 0, 0, 0, '', '- Strength bonus 30%'),

(16, 'Wrench', 'A weapon used to attack other mobsters.', 'weapon', 20000, 30000, 13, 0, 0, 0, 0, 0, '', '- Strength bonus 13%'),

(17, 'Machete', 'A weapon used to attack other mobsters.', 'weapon', 80000, 120000, 18, 0, 0, 0, 0, 0, '', '- Strength bonus 18%'),

(18, 'Medi-Kit (25%)', 'An item that heals yourself when used (HP).', 'consumable', 10000, 15000, 0, 0, 0, 0, 0, 0, 'http://mafiakillerz.co.cc/img/items/18.jpg', '- HP Restore: 25%'),

(19, 'Medi-Kit (50%)', 'An item that heals yourself when used (HP).', 'consumable', 15000, 22500, 0, 0, 0, 0, 0, 0, 'http://mafiakillerz.co.cc/img/items/19.jpg', '- HP Restore: 50%'),

(20, 'Medi-Kit (75%)', 'An item that heals yourself when used (HP).', 'consumable', 20000, 30000, 0, 0, 0, 0, 0, 0, 'http://mafiakillerz.co.cc/img/items/20.jpg', '- HP Restore: 75%'),

(21, 'Medi-Kit (100%)', 'An item that heals yourself when used (HP).', 'consumable', 25000, 37500, 0, 0, 0, 0, 0, 0, 'http://mafiakillerz.co.cc/img/items/21.jpg', '- HP Restore: 100%'),

(22, 'Police Revolver', 'A weapon used to attack other mobsters.', 'weapon', 320000, 480000, 36, 0, 0, 0, 0, 0, '', '- Strength bonus: 36%'),

(23, '1911 Colt', 'A weapon used to attack other mobsters.', 'weapon', 500000, 750000, 40, 0, 0, 0, 0, 0, '', '- Strength bonus: 40%'),

(24, 'Sawn-off Shotgun', 'A weapon used to attack other mobsters.', 'weapon', 620000, 930000, 43, 0, 0, 0, 0, 0, '', '- Strength bonus: 43%'),

(25, 'Pump Action Shotgun', 'A weapon used to attack other mobsters.', 'weapon', 650000, 975000, 45, 0, 0, 0, 0, 0, '', '- Strength bonus: 45%'),

(26, '1927 Thompson', 'A weapon used to attack other mobsters.', 'weapon', 900000, 1350000, 50, 0, 0, 0, 0, 0, '', '- Strength bonus: 50%'),

(27, 'Medical Certificate (25%)', 'An item that reduces your stay in hospital when used.', 'consumable', 30000, 45000, 0, 0, 0, 0, 0, 0, '', '- Hospital time: - 25%'),

(28, 'Medical Certificate (50%)', 'An item that reduces your stay in hospital when used.', 'consumable', 45000, 67500, 0, 0, 0, 0, 0, 0, '', '- Hospital time: - 50%'),

(29, 'Medical Certificate (75%)', 'An item that reduces your stay in hospital when used.', 'consumable', 60000, 90000, 0, 0, 0, 0, 0, 0, '', '- Hospital time: - 75%'),

(30, 'Medical Certificate (100%)', 'An item that reduces your stay in hospital when used.', 'consumable', 75000, 112500, 0, 0, 0, 0, 0, 0, '', '- Hospital time: - 100%'),

(31, 'Interceptor Body Armour', 'A piece of armour used to defend yourself from other mobster attacks.', 'armour', 650000, 975000, 0, 45, 0, 0, 0, 0, '', '- Defense bonus: 45%'),

(32, 'Modular Tactical Vest', 'A piece of armour used to defend yourself from other mobster attacks.', 'armour', 500000, 750000, 0, 40, 0, 0, 0, 0, '', '- Defense bonus: 40%'),

(33, 'Luger P08', 'A weapon used to attack other mobster.', 'weapon', 280000, 420000, 33, 0, 0, 0, 0, 0, '', '- Defense bonus: 33%'),

(34, 'Jehrico 941F', 'A weapon used to attack other mobsters.', 'weapon', 470000, 705000, 38, 0, 0, 0, 0, 0, '', '- Strength bonus: 38%'),

(35, 'Browning Hi-Power', 'A weapon used to attack other mobsters.', 'weapon', 540000, 810000, 42, 0, 0, 0, 0, 0, '', '- Strength bonus: 42%'),

(36, 'CMP-150', 'A weapon used to attack other mobster.', 'weapon', 400000, 600000, 37, 0, 0, 0, 0, 0, '', '- Strength bonus: 37%'),

(37, 'MP40', 'A weapon used to attack other mobsters.', 'weapon', 490000, 735000, 39, 0, 0, 0, 0, 0, '', '- Strength bonus: 39%'),

(38, 'MP5', 'A weapon used to attack other mobsters.', 'weapon', 520000, 780000, 41, 0, 0, 0, 0, 0, '', '- Strength bonus: 41%'),

(39, 'DW-P5', 'A weapon used to attack other mobsters.', 'weapon', 630000, 945000, 44, 0, 0, 0, 0, 0, '', '- Strength bonus: 44%'),

(40, 'Gewehr 3', 'A weapon used to attack other mobsters.', 'weapon', 800000, 1200000, 48, 0, 0, 0, 0, 0, '', '- Strength bonus: 48%'),

(41, 'RCP90', 'A weapon used to attack other mobsters.', 'weapon', 1200000, 1800000, 54, 0, 0, 0, 0, 0, '', '- Strength bonus: 54%'),

(42, 'FN SCAR', 'A weapon used to attack other mobsters.', 'weapon', 1400000, 2100000, 57, 0, 0, 0, 0, 0, '', '- Strength bonus: 57%'),

(43, 'Flak Jacket', 'A piece of armour used to defend yourself from other mobster attacks.', 'armour', 800000, 1200000, 0, 50, 0, 0, 0, 0, '', '- Defense bonus: 50%'),

(44, 'Panzer 1918', 'A piece of armour used to defend yourself from other mobster attacks.', 'armour', 240000, 360000, 0, 30, 0, 0, 0, 0, '', '- Defense bonus: 30%'),

(45, 'Cannabis', 'A drug that boosts your stats temporarily.', 'consumable', 28000, 42000, 5, 10, 5, 0, 0, 0, '', '- Strength bonus: 5%, Defense bonus: 10%, Speed bonus: 5% '),

(46, 'Speed', 'A drug that boosts your stats temporarily.', 'consumable', 56000, 84000, 10, 10, 20, 0, 0, 0, '', '- Strength bonus: 10%, Defense bonus: 10%, Speed bonus: 20% '),

(47, 'LSD', 'A drug that boosts your stats temporarily.', 'consumable', 80000, 120000, 25, 20, 15, 0, 0, 0, '', '- Strength bonus: 25%, Defense bonus: 20%, Speed bonus: 15% '),

(48, 'Cocaine', 'A drug that boosts your stats temporarily.', 'consumable', 108000, 162000, 25, 25, 30, 0, 0, 0, '', '- Strength bonus: 25%, Defense bonus: 25%, Speed bonus: 30% '),

(49, 'Heroin', 'A drug that boosts your stats temporarily.', 'consumable', 140000, 210000, 35, 35, 30, 0, 0, 0, '', '- Strength bonus: 35%, Defense bonus: 35%, Speed bonus: 30% '),

(50, 'Acura V6', 'A V6 engine to power your car.', 'parts', 40000, 60000, 0, 0, 0, 240, 220, 200, '', '- Power bonus: 240, Torque bonus: 220, Weight bonus: 200 '),

(51, 'Subaru Opposed-4', 'An Opposed-4 engine to power your car.', 'parts', 28000, 42000, 0, 0, 0, 200, 160, 140, '', '- Power bonus: 200, Torque bonus: 160, Weight bonus: 140 '),

(52, 'Nissan I6', 'An I6 engine to power your car.', 'parts', 16000, 24000, 0, 0, 0, 130, 160, 140, '', '- Power bonus: 130, Torque bonus: 160, Weight bonus: 140 '),

(53, 'Ford Small Block V8', 'A Small Block V8 to power your car.', 'parts', 53000, 80000, 0, 0, 0, 160, 230, 200, '', '- Power bonus: 160, Torque bonus: 230, Weight bonus: 200 '),

(54, 'Ford Big Block V8', 'A Big Block V8 to power your car.', 'parts', 0, 0, 0, 0, 0, 270, 340, 260, '', '- Power bonus: 270, Torque bonus: 340, Weight bonus: 260 '),

(55, 'Ford V6', 'A V6 engine to power your car.', 'parts', 21000, 32000, 0, 0, 0, 100, 170, 150, '', '- Power bonus: 100, Torque bonus: 170, Weight bonus: 150 '),

(56, 'Stock Exhaust', 'A stock exhaust for your car.', 'parts', 8000, 12000, 0, 0, 0, 15, 0, 5, '', '- Power bonus: 15, Torque bonus: 0, Weight bonus: 5 '),

(57, 'Dual Exhausts', 'Dual exhausts for your car.', 'parts', 13000, 20000, 0, 0, 0, 30, 0, 15, '', '- Power bonus: 30, Torque bonus: 0, Weight bonus: 15 '),

(58, 'Performance Exhaust', 'A performance exhaust for your car.', 'parts', 16000, 24000, 0, 0, 0, 35, 0, 5, '', '- Power bonus: 35, Torque bonus: 0, Weight bonus: 5 '),

(59, 'Quad Exhausts', 'Quad Exhausts for your car.', 'parts', 0, 0, 0, 0, 0, 60, 0, 30, '', '- Power bonus: 60, Torque bonus: 0, Weight bonus: 30 '),

(60, 'Small Turbocharger', 'A small turbocharger for your car.', 'parts', 23000, 35000, 0, 0, 0, 50, 90, 20, '', '- Power bonus: 50, Torque bonus: 90, Weight bonus: 20 '),

(61, 'Large Turbocharger', 'A large turbocharger for your car.', 'parts', 40000, 60000, 0, 0, 0, 80, 140, 30, '', '- Power bonus: 80, Torque bonus: 140, Weight bonus: 30 '),

(62, 'Stock Suspension', 'Stock Suspension for your car.', 'parts', 22000, 34000, 0, 0, 0, 0, 0, 250, '', '- Power bonus: 0, Torque bonus: 0, Weight bonus: 250 '),

(63, 'Racing Suspension', 'Racing Suspension for your car.', 'parts', 43000, 65000, 0, 0, 0, 0, 0, 120, '', '- Power bonus: 0, Torque bonus: 0, Weight bonus: 120 '),

(64, 'Small Supercharger', 'A small supercharger for your car.', 'parts', 35000, 50000, 0, 0, 0, 80, 140, 35, '', '- Power bonus: 80, Torque bonus: 140, Weight bonus: 35 '),

(65, 'Large Supercharger', 'A large supercharger for your car.', 'parts', 0, 0, 0, 0, 0, 170, 230, 60, '', '- Power bonus: 170, Torque bonus: 230, Weight bonus: 60 '),

(66, 'Dual Performance Exhausts', 'Dual Performance Exhausts for your car.', 'parts', 0, 0, 0, 0, 0, 45, 0, 15, '', '- Power bonus: 45, Torque bonus: 0, Weight bonus: 15 '),

(67, 'Subaru Flat-4', 'A Flat-4 engine to power your car.', 'parts', 40000, 60000, 0, 0, 0, 210, 260, 120, '', '- Power bonus: 210, Torque bonus: 260, Weight bonus: 120 '),

(68, 'Mazda Double Rotary', 'A Double Rotary Engine to power your car.', 'parts', 80000, 120000, 0, 0, 0, 230, 260, 180, '', ''),

(69, 'Strength Up (+5)', 'Increases your pet''s strength!', 'pet', 80000, 120000, 5, 0, 0, 0, 0, 0, '', ''),

(70, 'Defense Up (+5)', 'Increases your pet''s defense!', 'pet', 80000, 120000, 0, 5, 0, 0, 0, 0, '', ''),

(71, 'Speed Up (+5)', 'Increases your pet''s speed!', 'pet', 80000, 120000, 0, 0, 5, 0, 0, 0, '', ''),

(72, 'HP Up (+5)', 'Increases your pet''s HP!\r\n', 'pet', 120000, 180000, 0, 0, 0, 0, 0, 0, '', ''),

(73, 'Christmas Hat (2007)', 'A rare item from the Christmas period of 2009!', 'rare', 0, 0, 0, 0, 0, 0, 0, 0, '', ''),

(74, 'Christmas Cracker (2007)', 'A rare item from the Christmas period of 2007!', 'rare', 0, 0, 0, 0, 0, 0, 0, 0, '', ''),

(75, 'Colt King Cobra', 'A weapon used to attack other mobsters.\r\n', 'weapon', 1000000, 1500000, 52, 0, 0, 0, 0, 0, '', ''),

(76, 'AK-47', 'A weapon used to attack other mobsters.', 'weapon', 1900000, 2850000, 59, 0, 0, 0, 0, 0, '', ''),

(77, 'RPG-7', 'A weapon used to attack other mobsters.', 'weapon', 2800000, 4200000, 65, 0, 0, 0, 0, 0, '', ''),

(78, 'DragonSkin Tactical Vest', 'A piece of armour used to defend yourself from other mobster attacks.', 'armour', 1200000, 1800000, 0, 54, 0, 0, 0, 0, '', ''),

(79, 'Camouflage Vest', 'A piece of armour used to defend yourself from other mobster attacks.', 'armour', 1500000, 2250000, 0, 57, 0, 0, 0, 0, '', ''),

(80, 'Easter Egg', 'A rare item from the Easter period of 2009!', 'rare', 0, 0, 0, 0, 0, 0, 0, 0, '', ''),

(81, 'Chevrolet 7.0L LS7', 'A 7.0L LS7 to power your car.', 'parts', 0, 0, 0, 0, 0, 331, 380, 275, '', ''),

(82, 'Butterfly Knife', 'A weapon used to attack other citizens.', 'weapon', 360000, 540000, 37, 0, 0, 0, 0, 0, '', ''),

(83, 'M4 Carbine', 'A weapon used to attack other mobsters.', 'weapon', 2300000, 3450000, 61, 0, 0, 0, 0, 0, '', ''),

(84, 'HK USP45 Silenced', 'A weapon used to attack other mobsters.', 'weapon', 1400000, 2100000, 54, 0, 0, 0, 0, 0, '', ''),

(85, 'STF Liquid Armour', 'A piece of armour used to defend yourself from other citizen mobsters.', 'armour', 2800000, 4200000, 0, 65, 0, 0, 0, 0, '', ''),

(86, 'Moccasins', 'Shoes used to increase your speed in battle.', 'shoe', 5000, 7500, 0, 0, 3, 0, 0, 0, '', ''),

(87, 'Thongs', 'Shoes used to increase your speed in battle.', 'shoe', 25000, 37500, 0, 0, 6, 0, 0, 0, '', ''),

(88, 'Steel Sandals', 'Shoes used to increase your speed in battle.', 'shoe', 100000, 150000, 0, 0, 10, 0, 0, 0, '', ''),

(89, 'Cowboy Boots', 'Shoes used to increase your speed in battle.', 'shoe', 160000, 240000, 0, 0, 16, 0, 0, 0, '', ''),

(90, 'Aussie Work Boots', 'Shoes used to increase your speed in battle.', 'shoe', 240000, 360000, 0, 0, 19, 0, 0, 0, '', ''),

(91, 'Walking Shoes', 'Shoes used to increase your speed in battle.', 'shoe', 350000, 525000, 0, 0, 26, 0, 0, 0, '', ''),

(92, 'Sneakers', 'Shoes used to increase your speed in battle.', 'weapon', 900000, 1200000, 0, 0, 34, 0, 0, 0, '', ''),

(93, 'Runners', 'Shoes used to increase your speed in battle.', 'shoe', 1600000, 2400000, 0, 0, 40, 0, 0, 0, '', ''),

(94, 'Track Shoes', 'Shoes used to increase your speed in battle.', 'shoe', 2400000, 3600000, 0, 0, 48, 0, 0, 0, '', ''),

(95, 'Stilettos', 'Shoes used to increase your speed in battle.', 'shoe', 1200000, 1800000, 0, 0, 37, 0, 0, 0, '', '');

 

-- --------------------------------------------------------

 

--

-- Table structure for table `items`

--

 

CREATE TABLE IF NOT EXISTS `items` (

  `id` int(11) NOT NULL AUTO_INCREMENT,

  `player_id` int(11) NOT NULL DEFAULT '0',

  `item_id` int(11) NOT NULL DEFAULT '0',

  `quantity` int(11) NOT NULL,

  `status` enum('equipped','unequipped') COLLATE latin1_general_ci NOT NULL DEFAULT 'unequipped',

  PRIMARY KEY (`id`)

) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=23 ;

 

--

-- Dumping data for table `items`

--

 

INSERT INTO `items` (`id`, `player_id`, `item_id`, `quantity`, `status`) VALUES

(10, 1, 2, 1, 'unequipped'),

(22, 1, 19, 60, 'unequipped'),

(12, 1, 1, 31, 'unequipped'),

(20, 1, 11, 5, 'unequipped'),

(21, 1, 13, 1, 'unequipped'),

(15, 1, 30, 2, 'unequipped'),

(19, 1, 6, 20, 'unequipped'),

(17, 1, 18, 3, 'unequipped'),

(18, 1, 3, 1, 'unequipped');

 

<?php
include("lib.php");
define("PAGENAME", "MafiaKillerz");
$player = check_user($secret_key, $db);

if ($_GET['equip']){

$query = $db->execute("SELECT * FROM items WHERE player_id='$player->id' && id='".$_GET['equip']."'");
$item = $query->fetchrow();

$query2 = $db->execute("select * from `blueprint_items` where `id`=?",array($item['item_id']));
$item2 = $query2->fetchrow();		

if (($item2['type'] != 'weapon') && ($item2['type'] != 'armour') && ($item2['type'] != 'shoe')){

header('Location: inventory.php');	
die;
}
if ($item['status'] == 'equipped')
{
header('Location: inventory.php');	
die;
}

if ($item['status'] == 'unequipped')
{
//See if there is already a equipped item of that type.
//get info from items where player_id is player->id and status = equipped.
$query3 = $db->execute("SELECT * FROM items WHERE player_id='$player->id' && status='equipped'");	
$eitem = $query3->fetchrow();

$query4 = $db->execute("SELECT * FROM blueprint_items WHERE id='".$item['eitem_id']."' && type='".$item2['type']."'");
$bitem = $query4->fetchrow();
$count = $query4->recordcount();

echo "QUERY4 RECORD COUNT:".$count.".<br><br> BITEM RECORD COUNT:".$count2."";

echo"ALREADY IN DATABASE";	
echo $eitem['id'];
echo $eitem['status'];
echo $eitem['player_id'];
echo "<br><br><br><br> NO IT DATABASE!";
echo $item['id'];
echo $eitem['status'];
echo $eitem['player_id'];

echo "".$item2['type']."<br>";
echo "".$item3['type']."<br>";
echo "".$fitem['type']."<br>";

if ($count <= 0)
{
$eqquipitem	= $db->execute("update `items` set `status`=? where `item_id`=?", array('equipped', $item['item_id']));		
echo "NUMBER 2";
die;
break;
}

//if ITEM 3 finds 1 or more record:
if ($count >= 1){

$q1 = $db->execute("update `items` set `status`=? where `id`=?", array('unequipped', $eitem['id']));	
$q2	= $db->execute("update `items` set `status`=? where `item_id`=?", array('equipped', $item['item_id']));
echo "NUMBER 1";
die;
break;	
}
}
}
include("templates/private_header3.php");

 

the problem im having is even though the echo's that include $eitem do echo.

 

The recordcount for some reason is 0...

 

p.s: sorry if this confuses anyone!!

Link to comment
Share on other sites

Are you trying to get the number of records in the database with recordcount?

 

if so you can do something like this to get the number of records in a table.

$result = mysql_query("SELECT COUNT(id) AS numRows FROM table");
$numRowsTotal = mysql_result($result, 0, 'numRows');

 

COUNT(id) the (id) can really be any table field name in your table but id is probably the most commenly counted to retriveve the number of records in a table. then just store that number in a variable name of your choosing in this cause it stores the number in my variable I called $numRowsTotal.

 

 

Hope thats what you were looking to do if not please explain further and I will try to help more.

Link to comment
Share on other sites

Are you trying to get the number of records in the database with recordcount?

 

if so you can do something like this to get the number of records in a table.

$result = mysql_query("SELECT COUNT(id) AS numRows FROM table");
$numRowsTotal = mysql_result($result, 0, 'numRows');

 

COUNT(id) the (id) can really be any table field name in your table but id is probably the most commenly counted to retriveve the number of records in a table. then just store that number in a variable name of your choosing in this cause it stores the number in my variable I called $numRowsTotal.

 

 

Hope thats what you were looking to do if not please explain further and I will try to help more.

 

 

can i add something like this to the query?

 

$result = mysql_query("SELECT COUNT(id) AS numRows FROM table WHERE id='5' && equipped='equipped'");
$numRowsTotal = mysql_result($result, 0, 'numRows');

Link to comment
Share on other sites

okay well to make this all a little easier ill ask this....

 

//See if there is already a equipped item of that type.
//get info from items where player_id is player->id and status = equipped.
$query3 = $db->execute("SELECT * FROM items WHERE player_id='$player->id' && status='equipped'");	
$eitem = $query3->fetchrow();

$query4 = $db->execute("SELECT * FROM blueprint_items WHERE id='".$eitem['item_id']."' && type='".$item2['type']."'");
$bitem = $query4->fetchrow();

 

all i wanna do is check the recordcount this

 

(from blueprint_items table)

type = $item2['type'] AND id = $eitem['item_id']

 

AND

 

(from items table)

player_id = $player->id AND status = 'equipped'

 

 

Link to comment
Share on other sites

Are you trying to get the number of records in the database with recordcount?

 

if so you can do something like this to get the number of records in a table.

$result = mysql_query("SELECT COUNT(id) AS numRows FROM table");
$numRowsTotal = mysql_result($result, 0, 'numRows');

 

COUNT(id) the (id) can really be any table field name in your table but id is probably the most commenly counted to retriveve the number of records in a table. then just store that number in a variable name of your choosing in this cause it stores the number in my variable I called $numRowsTotal.

 

 

Hope thats what you were looking to do if not please explain further and I will try to help more.

 

 

can i add something like this to the query?

 

$result = mysql_query("SELECT COUNT(id) AS numRows FROM table WHERE id='5' && equipped='equipped'");
$numRowsTotal = mysql_result($result, 0, 'numRows');

 

Well you can pretty much add anything to your code as long as what your adding exisit in the database other wise just spit back errors.

 

I'm really not sure what your trying to do or what this script does so its hard for me to figure out exactly what your trying to accomplish. With that being said the sample code I gave you was assuming you where just trying to count the number of records in a database table. Therefor the code example is an sql query that contacts the database and gets the number of records in that table and stores them in a variable.

 

So say your table has 5 records you run that query statement the value that is stored in the variable $numRowsTotal would be 5. Until more records are stored in the database then it would reflect that number.

 

In your post where you changed the code to say WHERE id='5' should work but it would only return 1 record that record being the table id field that is 5 and if there is no id 5 nothing will return and the value you the variable that is storing it will be 0. So I really dont see a point of including a WHERE clause when trying to get the total number of records in a table.

 

Now a WHERE clause would work if for example in your table you have rows that have the same information. say for example you have the word "APPLE" in a field called fruit, say you have a total of 10 records in the table but "APPLE" areas in 4 out of the 10 records. So you would use a WHERE fruit = "APPLE" to pull out just the number of records for the word APPLE then it would store 4 in the numRowsTotal varaible.

 

Hope that helps explain a bit better sorry If I cant help more if you explain what your trying to do a bit more I might be able to be more insightful or hopefully someone else sees this and chimes in that knows more then me to help. I know the feeling being stuck on something like this. I think we all been there.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.