corruptcity || skalman Posted December 4, 2009 Posted December 4, 2009 ok im trying to make it that when you equip a wep in the users table it saves where the files can be found but im having problems getting it to work instead of doing what i want it to do its chucking out a SQL error and showing the pic instead of just equiping the weapon im gonna post the alter sql and the code and hopefully some1 can point me in the right direction here is the alter sql [mysql] ALTER TABLE `users` ADD `primarypic` VARCHAR( 255 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL ALTER TABLE `users` ADD `secondarypic` VARCHAR( 255 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL [/mysql] here is the stock equip_weapon plus my little bit of code <?php include "globals.php"; $_GET['ID'] = abs((int) $_GET['ID']); $id=$db->query("SELECT iv.*,it.* FROM inventory iv LEFT JOIN items it ON iv.inv_itemid=it.itmid WHERE iv.inv_id={$_GET['ID']} AND iv.inv_userid=$userid LIMIT 1"); if($db->num_rows($id)==0) { print "Invalid item ID"; $h->endpage(); exit; } else { $r=$db->fetch_row($id); } if(!$r['weapon']) { print "This item cannot be equipped to this slot."; $h->endpage(); exit; } if($_GET['type']) { if(!in_array($_GET['type'], array("equip_primary", "equip_secondary"))) { print "This slot ID is not valid."; $h->endpage(); exit; } if($ir[$_GET['type']]) { item_add($userid, $ir[$_GET['type']], 1); } item_remove($userid, $r['itmid'], 1); $db->query("UPDATE users SET {$_GET['type']} = {$r['itmid']} WHERE userid={$userid}"); if($r['itmpic']) { $itmpic = "[img=itmpics/".$r[]query("UPDATE users SET secendarypic = '{$itmpic}' WHERE userid={$userid}"); } else { $db->query("UPDATE users SET primarypic = '{$itmpic}' WHERE userid={$userid}"); } print "Item {$r['itmname']} equipped successfully."; } else { print "<h3>Equip Weapon</h3><hr /> <form action='equip_weapon.php' method='get'> <input type='hidden' name='ID' value='{$_GET['ID']}' /> Please choose the slot to equip {$r['itmname']} to, if there is already a weapon in that slot, it will be removed back to your inventory. <input type='radio' name='type' value='equip_primary' checked='checked' /> Primary <input type='radio' name='type' value='equip_secondary' /> Secondary <input type='submit' value='Equip Weapon' /></form>"; } $h->endpage(); ?> Quote
aburdet Posted December 9, 2009 Posted December 9, 2009 There's a VERY good chance I'm wrong here since I'm just STARTING to learn.... BUT.... Shouldn't $itmpic = "[img=itmpics/".$r[]}; Quote
corruptcity || skalman Posted December 11, 2009 Author Posted December 11, 2009 its ok now fixed it didnt need the <img src bit lol but thanks for the help Quote
Uridium Posted December 11, 2009 Posted December 11, 2009 Ive always found that the staff_items.php should Know wether an item is primary or secondary which would save time when equipping from the inventory Quote
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.