Not exactly sure why this code isn't working:
PHP Code:
function construct_items() {
global $db, $vbulletin;
$armors = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "armyarmors");
while ($armor = $db->fetch_array($armors)) {
$armor['price'] = vb_number_format($armor['price']);
$armor['strength'] = vb_number_format($armor['strength']);
eval('$arsenalarmorbit .= "' . fetch_template('army_arsenalarmorbit') . '";');
}
$weapons = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "armyweapons");
while ($weapon = $db->fetch_array($weapons)) {
$weapon['price'] = vb_number_format($weapon['price']);
$weapon['strength'] = vb_number_format($weapon['strength']);
eval('$arsenalweaponbit .= "' . fetch_template('army_arsenalweaponbit') . '";');
}
$defensive = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "armyarmors");
while ($defense = $db->fetch_array($defensive)) {
$item = $db->query_first("SELECT a" . $defense['id'] . " FROM " . TABLE_PREFIX . "armysys WHERE userid = " . $vbulletin->userinfo['userid']);
$item['name'] = $defense['name'];
$item['id'] = "a" . $offense['id'];
$item['quantity'] = vb_number_format($item[a . $defense['id']]);
$item['strength'] = vb_number_format($defense['strength']);
$item['cstrength'] = vb_number_format($item['cstrength']);
$item['sellprice'] = vb_number_format( ($defense['price']) * ('.' . $vbulletin->options['armysys_sellback_percent']) );
$item['repairprice'] = vb_number_format( ($defense['strength'] * '.' . $vbulletin->options['armysys_repair_percent']) * ( ($defense['strength'] - $defense['cstrength']) * ($item[w . $defense['id']]) ) );
if ($item[a . $defense['id']] > 0) eval('$arsenalarmorsbit .= "' . fetch_template('army_arsenalarmorsbit') . '";');
}
$offensive = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "armyweapons");
while ($offense = $db->fetch_array($offensive)) {
$item = $db->query_first("SELECT w" . $offense['id'] . " FROM " . TABLE_PREFIX . "armysys WHERE userid = " . $vbulletin->userinfo['userid']);
$item['name'] = $offense['name'];
$item['id'] = "w" . $offense['id'];
$item['quantity'] = vb_number_format($item[w . $offense['id']]);
$item['strength'] = vb_number_format($offense['strength']);
$item['cstrength'] = vb_number_format($item['cstrength']);
$item['sellprice'] = vb_number_format( ($offense['price']) * ('.' . $vbulletin->options['armysys_sellback_percent']) );
$item['repairprice'] = vb_number_format( ($offense['strength'] * '.' . $vbulletin->options['armysys_repair_percent']) * ( ($offense['strength'] - $offense['cstrength']) * ($item[w . $offense['id']]) ) );
if ($item[w . $offense['id']] > 0) eval('$arsenalweaponsbit .= "' . fetch_template('army_arsenalweaponsbit') . '";');
}
}
In the same page I am calling the function with:
PHP Code:
construct_items();
If I don't use the code in a function it correctly evals the code, but if I try a function it does not do anything.