Hi everyone
I have this piece of code below that I need help with ;D
A brief description of what the code is suppose to do, it’s to create a item and stores the item in the “Items” section of the database. That works fine.
Now what I want to do is add an extra feature, when it creates the item and stores it, I also want it to also deposit that item into the user’s account “Inventory”. I am really new to php programming so this code was inherited by me. I tried to add the code below in bold hoping it would do the trick but I failed miserably :’( It still creates the item and stores it in "Items’ but it does not store a copy of it in “Inventory” specifically in the session ID of the user creating the item.
If anyone can help see what I did wrong or tell me what I should add, I would truly appreciate it, I have been wrecking my brain for the past few days trying to figure out Thanks in advance
$create=1;
if($createitem){
if(($session['status'] == 9) || ($session['status'] == 5) || ($session['status'] == 1)){
$name = $itemName;
$type = $itemType;
if($itemType2){ $type = "$itemType2 $type"; }
$equip = $itemEquip;
$lvl = $itemLvl;
$avail = $itemAvail;
$damage = $dmg;
$heal = 0;
$armor = $armor;
$stamina = $stm;
$strength = $str;
$intellect = $int;
$agility = $agi;
$spirit = $spi;
$worth = 0;
$QTY = 0;
if(!$session['username']){
$user = mysql_fetch_array(mysql_query("SELECT username FROM $tab[account] WHERE id='$session[aid]';"));
$session['username'] = $user['username'];
}
$createdby = ucfirst($session['username']);
mysql_query("INSERT INTO items (name,type,equip,lvl,avail,damage,heal,armor,stamina,strength,intellect,agility,spirit,worth,QTY,createdby) VALUES ('$name','$type','$equip','$lvl','$avail','$damage','$heal','$armor','$stamina','$strength','$intellect','$agility','$spirit','$worth','$QTY','$createdby');");
[b]mysql_query("INSERT INTO inventory WHERE hid='$session[id]'(hid,name,type,equip,lvl,avail,damage,armor,stamina,strength,spirit,agility,intellect) WHERE id='$session[id]';");[/b]
header("Location: additem.php?success=1"); die();
}else{ $msg="You don't have permission to create or modify items."; }