boionfire81 Posted June 27, 2016 Share Posted June 27, 2016 I'm working here on 1 item. A rifle, itemid 297 itmtype 15 $q=$db->query("SELECT `inv_userid`, `inv_itemid`, `itmtype` FROM `inventory` AS iv INNER JOIN `items` AS i ON iv.inv_itemid=i.itmid WHERE iv.inv_userid={$ir['userid']} AND i.itmid={$_GET['ID']}"); $r=$db->fetch_row($q); if($r['itmtype'] !== 15) { echo "This item is not a Gun!<br /> <a href='inventory.php' class='button'>Exit</a>"; $h->endpage(); exit; } But it keeps giving me that ^ portion of the script. Also tried if($db->num_rows($q)==0) Quote Link to comment Share on other sites More sharing options...
NonStopCoding Posted June 27, 2016 Share Posted June 27, 2016 I'm working here on 1 item. A rifle, itemid 297 itmtype 15 $q=$db->query("SELECT `inv_userid`, `inv_itemid`, `itmtype` FROM `inventory` AS iv INNER JOIN `items` AS i ON iv.inv_itemid=i.itmid WHERE iv.inv_userid={$ir['userid']} AND i.itmid={$_GET['ID']}"); $r=$db->fetch_row($q); if($r['itmtype'] !== 15) { echo "This item is not a Gun!<br /> <a href='inventory.php' class='button'>Exit</a>"; $h->endpage(); exit; } But it keeps giving me that ^ portion of the script. Also tried if($db->num_rows($q)==0) instead of using the !== which is identical use the == (equals) so basicly try this $q = $db->query("SELECT `inv_userid`,`inv_itemid`,`itmtype` FROM `inventory` AS iv INNER JOIN `items` AS i ON `iv`.`inv_itemid` = `i`.`itmid` WHERE `iv`.`inv_userid` = {$ir['userid']} AND `i`.`itmid` = ".$_GET['ID']); // you are missing a row to check if the item is even real just assuming it is if(!$db->num_rows($q)) { $db->free_resources($q); echo "Invalid Item."; $h->endpage(); exit; } $r = $db->fetch_row($q); if(in_array($r['itmtype'],array(15))) { echo "This item is not a Gun!<br /> <a href='inventory.php' class='button'>Exit</a>"; $h->endpage(); exit; } if that fails try this $q = $db->query("SELECT `inv_userid`,`inv_itemid`,`itmtype` FROM `inventory` AS iv INNER JOIN `items` AS i ON `iv`.`inv_itemid` = `i`.`itmid` WHERE `iv`.`inv_userid` = {$ir['userid']} AND `iv`.`itmid` = ".$_GET['ID']); // you are missing a row to check if the item is even real just assuming it is if(!$db->num_rows($q)) { $db->free_resources($q); echo "Invalid Item."; $h->endpage(); exit; } $r = $db->fetch_row($q); if(in_array($r['itmtype'],array(15))) { echo "This item is not a Gun!<br /> <a href='inventory.php' class='button'>Exit</a>"; $h->endpage(); exit; } so basicly with the array option you need to add a , followed by another item type you wish to block Quote Link to comment Share on other sites More sharing options...
boionfire81 Posted June 28, 2016 Author Share Posted June 28, 2016 I will try that. But I don't want to block the itemtype I only want the item type gun (15) to allow ammo purchases. Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted June 28, 2016 Share Posted June 28, 2016 (edited) This is assuming you've sanitized the getdata $q = $db->query('SELECT `inv_userid`, `inv_itemid`, `itmname`, `itmtype` FROM `inventory` INNER JOIN `items` ON `inv_itemid` = `itmid` WHERE `inv_userid` = '.$ir['userid'].' AND `itmid` = '.$_GET['ID']); if(!$db->num_rows($q)) { echo 'Either that item doesn\'t exist or it\'s not yours'; exit($h->endpage()); } $r = $db->fetch_row($q); if($r['itmtype'] != 15) { echo 'You can\'t buy ammo for the '.$r['itmname']; exit($h->endpage()); } Edited June 28, 2016 by Magictallguy Quote Link to comment Share on other sites More sharing options...
NonStopCoding Posted June 28, 2016 Share Posted June 28, 2016 I will try that. But I don't want to block the itemtype I only want the item type gun (15) to allow ammo purchases. i know you only wanted to block gun but say in future you changed your mind the array was there blocking the gun already if you wanted to block a special item then you could addapt the code easy without adding || $r['itemtype'] == xx etc if that makes any sense to you but if not [uSER=53425]Magictallguy[/uSER] did it for you :P even tho it does the same thing 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.