Nicholas Posted October 2, 2009 Share Posted October 2, 2009 Hi, can someone help me please? im getting this fatal error on line 2, i cant figure the error out, can anyone help me please? Fatal error: Call to a member function query() on a non-object in ---------- on line 2 <?php $bat1=sprintf("SELECT ready FROM battlearena WHERE batid=%u", 1); $bat1=$db->query($bat1); $ba1=$db->fetch_row($bat1); $bat2=sprintf("SELECT ready FROM battlearena WHERE batid=%u", 2); $bat2=$db->query($bat2); $ba2=$db->fetch_row($bat2); $bat3=sprintf("SELECT ready FROM battlearena WHERE batid=%u", 3); $bat3=$db->query($bat3); $ba3=$db->fetch_row($bat3); $bat4=sprintf("SELECT ready FROM battlearena WHERE batid=%u", 4); $bat4=$db->query($bat4); $ba4=$db->fetch_row($bat4); $bat5=sprintf("SELECT ready FROM battlearena WHERE batid=%u", 5); $bat5=$db->query($bat5); $ba5=$db->fetch_row($bat5); if($ba1['ready']==1) {$mop=1;} elseif($ba2['ready']==1) {$mop=2;} elseif($ba3['ready']==1) {$mop=3;} elseif($ba4['ready']==1) {$mop=4;} elseif($ba5['ready']==1) {$mop=5;} else{$mop=0;} if($mop==0){die("<font color=white>Battle Arena is not ready yet");} $it=sprintf("SELECT * FROM battlearena WHERE batid=%u", $mop); $it=$db->query($it); $bat=$db->fetch_row($it); $qa=sprintf("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=%u", $bat['p1']); $qa=$db->query($qa); $a=$db->fetch_row($qa); $qb=sprintf("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=%u", $bat['p2']); $qb=$db->query($qb); $b=$db->fetch_row($qb); $qc=sprintf("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=%u", $bat['p3']); $qc=$db->query($qc); $c=$db->fetch_row($qc); $qd=sprintf("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=%u", $bat['p4']); $qd=$db->query($qd); $d=$db->fetch_row($qd); $qe=sprintf("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=%u", $bat['p5']); $qe=$db->query($qe); $e=$db->fetch_row($qe); $qf=sprintf("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=%u", $bat['p6']); $qf=$db->query($qf); $f=$db->fetch_row($qf); $qg=sprintf("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=%u", $bat['p7']); $qg=$db->query($qg); $g=$db->fetch_row($qg); $qh=sprintf("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=%u", $bat['p8']); $qh=$db->query($qh); $h=$db->fetch_row($qh); $qi=sprintf("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=%u", $bat['p9']); $qi=$db->query($qi); $i=$db->fetch_row($qi); $qj=sprintf("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=%u", $bat['p10']); $qj=$db->query($qj); $j=$db->fetch_row($qj); $wa=sprintf("SELECT * FROM items WHERE itmid=%u", $a['equip_primary']); $wa=$db->query($wa); $aa=$db->fetch_row($wa); $wb=sprintf("SELECT * FROM items WHERE itmid=%u", $b['equip_primary']); $wb=$db->query($wb); $bb=$db->fetch_row($wb); $wc=sprintf("SELECT * FROM items WHERE itmid=%u", $c['equip_primary']); $wc=$db->query($wc); $cc=$db->fetch_row($wc); $wd=sprintf("SELECT * FROM items WHERE itmid=%u", $d['equip_primary']); $wd=$db->query($wd); $dd=$db->fetch_row($wd); $we=sprintf("SELECT * FROM items WHERE itmid=%u", $e['equip_primary']); $we=$db->query($we); $ee=$db->fetch_row($we); $wf=sprintf("SELECT * FROM items WHERE itmid=%u", $f['equip_primary']); $wf=$db->query($wf); $ff=$db->fetch_row($wf); $wg=sprintf("SELECT * FROM items WHERE itmid=%u", $g['equip_primary']); $wg=$db->query($wg); $gg=$db->fetch_row($wg); $wh=sprintf("SELECT * FROM items WHERE itmid=%u", $h['equip_primary']); $wh=$db->query($wh); $hh=$db->fetch_row($wh); $wi=sprintf("SELECT * FROM items WHERE itmid=%u", $i['equip_primary']); $wi=$db->query($wi); $ii=$db->fetch_row($wi); $wj=sprintf("SELECT * FROM items WHERE itmid=%u", $j['equip_primary']); $wj=$db->query($wj); $jj=$db->fetch_row($wj); $pa=sprintf("SELECT * FROM items WHERE itmid=%u", $a['equip_armor']); $pa=$db->query($pa); $aaa=$db->fetch_row($pa); $pb=sprintf("SELECT * FROM items WHERE itmid=%u", $b['equip_armor']); $pb=$db->query($pb); $bbb=$db->fetch_row($pb); $pc=sprintf("SELECT * FROM items WHERE itmid=%u", $c['equip_armor']); $pc=$db->query($pc); $ccc=$db->fetch_row($pc); $pd=sprintf("SELECT * FROM items WHERE itmid=%u", $d['equip_armor']); $pd=$db->query($pd); $ddd=$db->fetch_row($pd); $pe=sprintf("SELECT * FROM items WHERE itmid=%u", $e['equip_armor']); $pe=$db->query($pe); $eee=$db->fetch_row($pe); $pf=sprintf("SELECT * FROM items WHERE itmid=%u", $f['equip_armor']); $pf=$db->query($pf); $fff=$db->fetch_row($pf); $pg=sprintf("SELECT * FROM items WHERE itmid=%u", $g['equip_armor']); $pg=$db->query($pg); $ggg=$db->fetch_row($pg); $ph=sprintf("SELECT * FROM items WHERE itmid=%u", $h['equip_armor']); $ph=$db->query($ph); $hhh=$db->fetch_row($ph); $pi=sprintf("SELECT * FROM items WHERE itmid=%u", $i['equip_armor']); $pi=$db->query($pi); $iii=$db->fetch_row($pi); $pj=sprintf("SELECT * FROM items WHERE itmid=%u", $j['equip_armor']); $pj=$db->query($pj); $jjj=$db->fetch_row($pj); if($a['hp']>0){$k=array(b, c, d, e, f, g, h, i, j);} if($b['hp']>0){$l=array(a, c, d, e, f, g, h, i, j);} if($c['hp']>0){$m=array(a, b, d, e, f, g, h, i, j);} if($d['hp']>0){$n=array(a, b, c, e, f, g, h, i, j);} if($e['hp']>0){$o=array(a, b, c, d, f, g, h, i, j);} if($f['hp']>0){$p=array(a, b, c, d, e, g, h, i, j);} if($g['hp']>0){$q=array(a, b, c, d, e, f, h, i, j);} if($h['hp']>0){$r=array(a, b, c, d, e, f, g, i, j);} if($i['hp']>0){$s=array(a, b, c, d, e, f, g, h, j);} if($j['hp']>0){$t=array(a, b, c, d, e, f, g, h, i);} if($a['hp']<1){unset($l[0], $m[0], $n[0], $o[0], $p[0], $q[0], $r[0], $s[0], $t[0]);} if($b['hp']<1){unset($k[0], $m[1], $n[1], $o[1], $p[1], $q[1], $r[1], $s[1], $t[1]);} if($c['hp']<1){unset($k[1], $l[1], $n[2], $o[2], $p[2], $q[2], $r[2], $s[2], $t[2]);} if($d['hp']<1){unset($k[2], $l[2], $m[2], $o[3], $p[3], $q[3], $r[3], $s[3], $t[3]);} if($e['hp']<1){unset($k[3], $l[3], $m[3], $n[3], $p[4], $q[4], $r[4], $s[4], $t[4]);} if($f['hp']<1){unset($k[4], $l[4], $m[4], $n[4], $o[4], $q[5], $r[5], $s[5], $t[5]);} if($g['hp']<1){unset($k[5], $l[5], $m[5], $n[5], $o[5], $p[5], $r[6], $s[6], $t[6]);} if($h['hp']<1){unset($k[6], $l[6], $m[6], $n[6], $o[6], $p[6], $q[6], $s[7], $t[7]);} if($i['hp']<1){unset($k[7], $l[7], $m[7], $n[7], $o[7], $p[7], $q[7], $r[7], $t[8]);} if($j['hp']<1){unset($k[8], $l[8], $m[8], $n[8], $o[8], $p[8], $q[8], $r[8], $s[8]);} if($a['hp']>0){$randaa=array_rand($k); $randa=$k[$randaa];} if($b['hp']>0){$randbb=array_rand($l); $randb=$l[$randbb];} if($c['hp']>0){$randcc=array_rand($m); $randc=$m[$randcc];} if($d['hp']>0){$randdd=array_rand($n); $randd=$n[$randdd];} if($e['hp']>0){$randee=array_rand($o); $rande=$o[$randee];} if($f['hp']>0){$randff=array_rand($p); $randf=$p[$randff];} if($g['hp']>0){$randgg=array_rand($q); $randg=$q[$randgg];} if($h['hp']>0){$randhh=array_rand($r); $randh=$r[$randhh];} if($i['hp']>0){$randii=array_rand($s); $randi=$s[$randii];} if($j['hp']>0){$randjj=array_rand($t); $randj=$t[$randjj];} if($a['hp']>0) {$aattack=(int) ($aa['weapon']*$a['strength']/(${$randa}['guard']*1.5)*(rand(8000,12000)/10000)-${$randa}{$randa}{$randa}['armor']);$aluck=rand(60,100); if($aattack<${$randa}['maxhp']/6){$aattack=rand(${$randa}['maxhp']/6, ${$randa}['maxhp']/2)-${$randa}{$randa}{$randa}['armor'];}} if($b['hp']>0) {$battack=(int) ($bb['weapon']*$b['strength']/(${$randb}['guard']*1.5)*(rand(8000,12000)/10000)-${$randb}{$randb}{$randb}['armor']);$bluck=rand(60,100); if($battack<${$randb}['maxhp']/6){$battack=rand(${$randb}['maxhp']/6, ${$randb}['maxhp']/2)-${$randb}{$randb}{$randb}['armor'];}} if($c['hp']>0) {$cattack=(int) ($cc['weapon']*$c['strength']/(${$randc}['guard']*1.5)*(rand(8000,12000)/10000)-${$randc}{$randc}{$randc}['armor']);$cluck=rand(60,100); if($cattack<${$randc}['maxhp']/6){$cattack=rand(${$randc}['maxhp']/6, ${$randc}['maxhp']/2)-${$randc}{$randc}{$randc}['armor'];}} if($d['hp']>0) {$dattack=(int) ($dd['weapon']*$d['strength']/(${$randd}['guard']*1.5)*(rand(8000,12000)/10000)-${$randd}{$randd}{$randd}['armor']);$dluck=rand(60,100); if($dattack<${$randd}['maxhp']/6){$dattack=rand(${$randd}['maxhp']/6, ${$randd}['maxhp']/2)-${$randd}{$randd}{$randd}['armor'];}} if($e['hp']>0) {$eattack=(int) ($ee['weapon']*$e['strength']/(${$rande}['guard']*1.5)*(rand(8000,12000)/10000)-${$rande}{$rande}{$rande}['armor']);$eluck=rand(60,100); if($eattack<${$rande}['maxhp']/6){$eattack=rand(${$rande}['maxhp']/6, ${$rande}['maxhp']/2)-${$rande}{$rande}{$rande}['armor'];}} if($f['hp']>0) {$fattack=(int) ($ff['weapon']*$f['strength']/(${$randf}['guard']*1.5)*(rand(8000,12000)/10000)-${$randf}{$randf}{$randf}['armor']);$fluck=rand(60,100); if($fattack<${$randf}['maxhp']/6){$fattack=rand(${$randf}['maxhp']/6, ${$randf}['maxhp']/2)-${$randf}{$randf}{$randf}['armor'];}} if($g['hp']>0) {$gattack=(int) ($gg['weapon']*$g['strength']/(${$randg}['guard']*1.5)*(rand(8000,12000)/10000)-${$randg}{$randg}{$randg}['armor']);$gluck=rand(60,100); if($gattack<${$randg}['maxhp']/6){$gattack=rand(${$randg}['maxhp']/6, ${$randg}['maxhp']/2)-${$randg}{$randg}{$randg}['armor'];}} if($h['hp']>0) {$hattack=(int) ($hh['weapon']*$h['strength']/(${$randh}['guard']*1.5)*(rand(8000,12000)/10000)-${$randh}{$randh}{$randh}['armor']);$hluck=rand(60,100); if($hattack<${$randh}['maxhp']/6){$hattack=rand(${$randh}['maxhp']/6, ${$randh}['maxhp']/2)-${$randh}{$randh}{$randh}['armor'];}} if($i['hp']>0) {$iattack=(int) ($ii['weapon']*$i['strength']/(${$randi}['guard']*1.5)*(rand(8000,12000)/10000)-${$randi}{$randi}{$randi}['armor']);$iluck=rand(60,100); if($iattack<${$randi}['maxhp']/6){$iattack=rand(${$randi}['maxhp']/6, ${$randi}['maxhp']/2)-${$randi}{$randi}{$randi}['armor'];}} if($j['hp']>0) {$jattack=(int) ($jj['weapon']*$j['strength']/(${$randj}['guard']*1.5)*(rand(8000,12000)/10000)-${$randj}{$randj}{$randj}['armor']);$jluck=rand(60,100); if($jattack<${$randj}['maxhp']/6){$jattack=rand(${$randj}['maxhp']/6, ${$randj}['maxhp']/2)-${$randj}{$randj}{$randj}['armor'];}} if($aattack>${$randa}['maxhp']) {$aattack=rand(${$randa}['maxhp']/4, ${$randa}['maxhp']);} if($battack>${$randb}['maxhp']) {$battack=rand(${$randb}['maxhp']/4, ${$randb}['maxhp']);} if($cattack>${$randc}['maxhp']) {$cattack=rand(${$randc}['maxhp']/4, ${$randc}['maxhp']);} if($dattack>${$randd}['maxhp']) {$dattack=rand(${$randd}['maxhp']/4, ${$randd}['maxhp']);} if($eattack>${$rande}['maxhp']) {$eattack=rand(${$rande}['maxhp']/4, ${$rande}['maxhp']);} if($fattack>${$randf}['maxhp']) {$fattack=rand(${$randf}['maxhp']/4, ${$randf}['maxhp']);} if($gattack>${$randg}['maxhp']) {$gattack=rand(${$randg}['maxhp']/4, ${$randg}['maxhp']);} if($hattack>${$randh}['maxhp']) {$hattack=rand(${$randh}['maxhp']/4, ${$randh}['maxhp']);} if($iattack>${$randi}['maxhp']) {$iattack=rand(${$randi}['maxhp']/4, ${$randi}['maxhp']);} if($jattack>${$randj}['maxhp']) {$jattack=rand(${$randj}['maxhp']/4, ${$randj}['maxhp']);} $rawa=rand(1,100); $rawb=rand(1,100); $rawc=rand(1,100); $rawd=rand(1,100); $rawe=rand(1,100); $rawf=rand(1,100); $rawg=rand(1,100); $rawh=rand(1,100); $rawi=rand(1,100); $rawj=rand(1,100); if($_session['plz']==10) {$z="";} if($a['hp']>1) { if(${$randa}['hp']<1){}else{ $_session['nsp']=$_session['nsp']+='1';$ns=$_session['nsp']; if($aluck>$rawa) { $qry=sprintf("UPDATE users SET hp=hp-%d WHERE userid=%d", $aattack, ${$randa}['userid']); $db->query($qry); ${$randa}['hp']=${$randa}['hp']-$aattack; if(${$randa}['hp']<1) {$_session['plz']=$_session['plz']-='1'; $dl="<font color=red>";}else{$dl="";} if($_session['plz']==0) {$lw2=${$randa}['username'];} if($_session['plz']==2) {$lw3=${$randa}['username']; $_session['plz']='1';} $z.="{$ns}.{$dl} {$a['username']} hit {${$randa}['username']} with his {$aa['itmname']} doing {$aattack} damage ({${$randa}['hp']})</font> ";} else{$z.="{$ns}. {$a['username']} tried to hit {${$randa}['username']} but missed ({${$randa}['hp']})</font> ";}} } if($b['hp']>1) { if(${$randb}['hp']<1){}else{ $_session['nsp']=$_session['nsp']+='1';$ns=$_session['nsp']; if($bluck>$rawb) { $qry=sprintf("UPDATE users SET hp=hp-%d WHERE userid=%d", $battack, ${$randb}['userid']); $db->query($qry); ${$randb}['hp']=${$randb}['hp']-$battack; if(${$randb}['hp']<1) {$_session['plz']=$_session['plz']-='1'; $dl="<font color=red>";}else{$dl="";} if($_session['plz']==0) {$lw2=${$randb}['username'];} if($_session['plz']==2) {$lw3=${$randb}['username']; $_session['plz']='1';} $z.="{$ns}.{$dl} {$b['username']} hit {${$randb}['username']} with his {$bb['itmname']} doing {$battack} damage ({${$randb}['hp']})</font> ";} else{$z.="{$ns}. {$b['username']} tried to hit {${$randb}['username']} but missed ({${$randb}['hp']})</font> ";}} } if($c['hp']>1) { if(${$randc}['hp']<0){}else{ $_session['nsp']=$_session['nsp']+='1';$ns=$_session['nsp']; if($cluck>$rawc) { $qry=sprintf("UPDATE users SET hp=hp-%d WHERE userid=%d", $cattack, ${$randc}['userid']); $db->query($qry); ${$randc}['hp']=${$randc}['hp']-$cattack; if(${$randc}['hp']<1) {$_session['plz']=$_session['plz']-='1'; $dl="<font color=red>";}else{$dl="";} if($_session['plz']==0) {$lw2=${$randc}['username'];} if($_session['plz']==2) {$lw3=${$randc}['username']; $_session['plz']='1';} $z.="{$ns}.{$dl} {$c['username']} hit {${$randc}['username']} with his {$cc['itmname']} doing {$cattack} damage ({${$randc}['hp']})</font> ";} else{$z.="{$ns}. {$c['username']} tried to hit {${$randc}['username']} but missed ({${$randc}['hp']})</font> ";}} } if($d['hp']>1) { if(${$randd}['hp']<0){}else{ $_session['nsp']=$_session['nsp']+='1';$ns=$_session['nsp']; if($dluck>$rawd) { $qry=sprintf("UPDATE users SET hp=hp-%d WHERE userid=%d", $dattack, ${$randd}['userid']); $db->query($qry); ${$randd}['hp']=${$randd}['hp']-$dattack; if(${$randd}['hp']<1) {$_session['plz']=$_session['plz']-='1'; $dl="<font color=red>";}else{$dl="";} if($_session['plz']==0) {$lw2=${$randd}['username'];} if($_session['plz']==2) {$lw3=${$randd}['username']; $_session['plz']='1';} $z.="{$ns}.{$dl} {$d['username']} hit {${$randd}['username']} with his {$dd['itmname']} doing {$dattack} damage ({${$randd}['hp']})</font> ";} else{$z.="{$ns}. {$d['username']} tried to hit {${$randd}['username']} but missed ({${$randd}['hp']})</font> ";}} } if($e['hp']>1) { if(${$rande}['hp']<0){}else{ $_session['nsp']=$_session['nsp']+='1';$ns=$_session['nsp']; if($eluck>$rawe) { $qry=sprintf("UPDATE users SET hp=hp-%d WHERE userid=%d", $eattack, ${$rande}['userid']); $db->query($qry); ${$rande}['hp']=${$rande}['hp']-$eattack; if(${$rande}['hp']<1) {$_session['plz']=$_session['plz']-='1'; $dl="<font color=red>";}else{$dl="";} if($_session['plz']==0) {$lw2=${$rande}['username'];} if($_session['plz']==2) {$lw3=${$rande}['username']; $_session['plz']='1';} $z.="{$ns}.{$dl} {$e['username']} hit {${$rande}['username']} with his {$ee['itmname']} doing {$eattack} damage ({${$rande}['hp']})</font> ";} else{$z.="{$ns}. {$e['username']} tried to hit {${$rande}['username']} but missed ({${$rande}['hp']})</font> ";}} } if($f['hp']>1) { if(${$randf}['hp']<0){}else{ $_session['nsp']=$_session['nsp']+='1';$ns=$_session['nsp']; if($fluck>$rawf) { $qry=sprintf("UPDATE users SET hp=hp-%d WHERE userid=%d", $fattack, ${$randf}['userid']); $db->query($qry); ${$randf}['hp']=${$randf}['hp']-$fattack; if(${$randf}['hp']<1) {$_session['plz']=$_session['plz']-='1'; $dl="<font color=red>";}else{$dl="";} if($_session['plz']==0) {$lw2=${$randf}['username'];} if($_session['plz']==2) {$lw3=${$randf}['username']; $_session['plz']='1';} $z.="{$ns}.{$dl} {$f['username']} hit {${$randf}['username']} with his {$ff['itmname']} doing {$fattack} damage ({${$randf}['hp']})</font> ";} else{$z.="{$ns}. {$f['username']} tried to hit {${$randf}['username']} but missed ({${$randf}['hp']})</font> ";}} } if($g['hp']>1) { if(${$randg}['hp']<0){}else{ $_session['nsp']=$_session['nsp']+='1';$ns=$_session['nsp']; if($gluck>$rawg) { $qry=sprintf("UPDATE users SET hp=hp-%d WHERE userid=%d", $gattack, ${$randg}['userid']); $db->query($qry); ${$randg}['hp']=${$randg}['hp']-$gattack; if(${$randg}['hp']<1) {$_session['plz']=$_session['plz']-='1'; $dl="<font color=red>";}else{$dl="";} if($_session['plz']==0) {$lw2=${$randg}['username'];} if($_session['plz']==2) {$lw3=${$randg}['username']; $_session['plz']='1';} $z.="{$ns}.{$dl} {$g['username']} hit {${$randg}['username']} with his {$gg['itmname']} doing {$gattack} damage ({${$randg}['hp']})</font> ";} else{$z.="{$ns}. {$g['username']} tried to hit {${$randg}['username']} but missed ({${$randg}['hp']})</font> ";}} } if($h['hp']>1) { if(${$randh}['hp']<0){}else{ $_session['nsp']=$_session['nsp']+='1';$ns=$_session['nsp']; if($hluck>$rawh) { $qry=sprintf("UPDATE users SET hp=hp-%d WHERE userid=%d", $hattack, ${$randh}['userid']); $db->query($qry); ${$randh}['hp']=${$randh}['hp']-$hattack; if(${$randh}['hp']<1) {$_session['plz']=$_session['plz']-='1'; $dl="<font color=red>";}else{$dl="";} if($_session['plz']==0) {$lw2=${$randh}['username'];} if($_session['plz']==2) {$lw3=${$randh}['username']; $_session['plz']='1';} $z.="{$ns}.{$dl} {$h['username']} hit {${$randh}['username']} with his {$hh['itmname']} doing {$hattack} damage ({${$randh}['hp']})</font> ";} else{$z.="{$ns}. {$h['username']} tried to hit {${$randh}['username']} but missed ({${$randh}['hp']})</font> ";}} } if($i['hp']>1) { if(${$randi}['hp']<0){}else{ $_session['nsp']=$_session['nsp']+='1';$ns=$_session['nsp']; if($iluck>$rawi) { $qry=sprintf("UPDATE users SET hp=hp-%d WHERE userid=%d", $iattack, ${$randi}['userid']); $db->query($qry); ${$randi}['hp']=${$randi}['hp']-$iattack; if(${$randi}['hp']<1) {$_session['plz']=$_session['plz']-='1'; $dl="<font color=red>";}else{$dl="";} if($_session['plz']==0) {$lw2=${$randi}['username'];} if($_session['plz']==2) {$lw3=${$randi}['username']; $_session['plz']='1';} $z.="{$ns}.{$dl} {$i['username']} hit {${$randi}['username']} with his {$ii['itmname']} doing {$iattack} damage ({${$randi}['hp']})</font> ";} else{$z.="{$ns}. {$i['username']} tried to hit {${$randi}['username']} but missed ({${$randi}['hp']})</font> ";}} } if($j['hp']>1) { if(${$randj}['hp']<0){}else{ $_session['nsp']=$_session['nsp']+='1';$ns=$_session['nsp']; if($jluck>$rawj) { $qry=sprintf("UPDATE users SET hp=hp-%d WHERE userid=%d", $jattack, ${$randj}['userid']); $db->query($qry); ${$randj}['hp']=${$randj}['hp']-$jattack; if(${$randj}['hp']<1) {$_session['plz']=$_session['plz']-='1'; $dl="<font color=red>";}else{$dl="";} if($_session['plz']==0) {$lw2=${$randj}['username'];} if($_session['plz']==2) {$lw3=${$randj}['username']; $_session['plz']='1';} $z.="{$ns}.{$dl} {$j['username']} hit {${$randj}['username']} with his {$jj['itmname']} doing {$jattack} damage ({${$randj}['hp']})</font> ";} else{$z.="{$ns}. {$j['username']} tried to hit {${$randj}['username']} but missed ({${$randj}['hp']})</font> ";}} } if($a['hp']>1 && $b['hp']<1 && $c['hp']<1 && $d['hp']<1 && $e['hp']<1 && $f['hp']<1 && $g['hp']<1 && $h['hp']<1 && $i['hp']<1 && $j['hp']<1) {$lw=$a['username'];$over=1;} elseif($a['hp']<1 && $b['hp']>1 && $c['hp']<1 && $d['hp']<1 && $e['hp']<1 && $f['hp']<1 && $g['hp']<1 && $h['hp']<1 && $i['hp']<1 && $j['hp']<1) {$lw=$b['username'];$over=2;} elseif($a['hp']<1 && $b['hp']<1 && $c['hp']>1 && $d['hp']<1 && $e['hp']<1 && $f['hp']<1 && $g['hp']<1 && $h['hp']<1 && $i['hp']<1 && $j['hp']<1) {$lw=$c['username'];$over=3;} elseif($a['hp']<1 && $b['hp']<1 && $c['hp']<1 && $d['hp']>1 && $e['hp']<1 && $f['hp']<1 && $g['hp']<1 && $h['hp']<1 && $i['hp']<1 && $j['hp']<1) {$lw=$d['username'];$over=4;} elseif($a['hp']<1 && $b['hp']<1 && $c['hp']<1 && $d['hp']<1 && $e['hp']>1 && $f['hp']<1 && $g['hp']<1 && $h['hp']<1 && $i['hp']<1 && $j['hp']<1) {$lw=$e['username'];$over=5;} elseif($a['hp']<1 && $b['hp']<1 && $c['hp']<1 && $d['hp']<1 && $e['hp']<1 && $f['hp']>1 && $g['hp']<1 && $h['hp']<1 && $i['hp']<1 && $j['hp']<1) {$lw=$f['username'];$over=6;} elseif($a['hp']<1 && $b['hp']<1 && $c['hp']<1 && $d['hp']<1 && $e['hp']<1 && $f['hp']<1 && $g['hp']>1 && $h['hp']<1 && $i['hp']<1 && $j['hp']<1) {$lw=$g['username'];$over=7;} elseif($a['hp']<1 && $b['hp']<1 && $c['hp']<1 && $d['hp']<1 && $e['hp']<1 && $f['hp']<1 && $g['hp']<1 && $h['hp']>1 && $i['hp']<1 && $j['hp']<1) {$lw=$h['username'];$over=8;} elseif($a['hp']<1 && $b['hp']<1 && $c['hp']<1 && $d['hp']<1 && $e['hp']<1 && $f['hp']<1 && $g['hp']<1 && $h['hp']<1 && $i['hp']>1 && $j['hp']<1) {$lw=$i['username'];$over=9;} elseif($a['hp']<1 && $b['hp']<1 && $c['hp']<1 && $d['hp']<1 && $e['hp']<1 && $f['hp']<1 && $g['hp']<1 && $h['hp']<1 && $i['hp']<1 && $j['hp']>1) {$lw=$j['username'];$over=10;} if($over>0) { $htt=sprintf("SELECT userid, hp FROM users WHERE userid=%d OR userid=%d OR userid=%d OR userid=%d OR userid=%d OR userid=%d OR userid=%d OR userid=%d OR userid=%d OR userid=%d", $bat['p1'], $bat['p2'], $bat['p3'], $bat['p4'], $bat['p5'], $bat['p6'], $bat['p7'], $bat['p8'], $bat['p9'], $bat['p10']); $htt=$db->query($htt); $qry=sprintf("UPDATE users SET ghonor=ghonor+%d WHERE username='%s'", 3, $lw); $db->query($qry); $qry=sprintf("UPDATE users SET ghonor=ghonor+%d WHERE username='%s'", 2, $lw2); $db->query($qry); $qry=sprintf("UPDATE users SET ghonor=ghonor+%d WHERE username='%s'", 1, $lw3); $db->query($qry); $lwi=sprintf("SELECT userid FROM users WHERE username='%s'", $lw); $lwi=$db->query($lwi); $lwid=$db->fetch_row($lwi); $az=sprintf("SELECT userid FROM users WHERE bet='%d'", $lwid['userid']); $az=$db->query($az); $bz=$db->num_rows($az); if($bz>0) {$hw=(int)($bat['p1b']+$bat['p2b']+$bat['p3b']+$bat['p4b']+$bat['p5b']+$bat['p6b']+$bat['p7b']+$bat['p8b']+$bat['p9b']+$bat['p10b']); $fw=(int)(($bat['p1b']+$bat['p2b']+$bat['p3b']+$bat['p4b']+$bat['p5b']+$bat['p6b']+$bat['p7b']+$bat['p8b']+$bat['p9b']+$bat['p10b'])/$bz); $qry=sprintf("UPDATE users SET crystals=crystals+%d WHERE bet='%d'", $fw, $lwid['userid']); $db->query($qry);} $qry=sprintf("UPDATE users SET bet=0 WHERE bet=%d OR bet=%d OR bet=%d OR bet=%d OR bet=%d OR bet=%d OR bet=%d OR bet=%d OR bet=%d OR bet=%d", $bat['p1'], $bat['p2'], $bat['p3'], $bat['p4'], $bat['p5'], $bat['p6'], $bat['p7'], $bat['p8'], $bat['p9'], $bat['p10']); $db->query($qry); while($se=$db->fetch_row($az)){event_add($se['userid'], "You have recieved {$fw} knifes for winning the bet in the battlearena.",$c);} while($ht=$db->fetch_row($htt)){if($ht['hp']<1) {$qry=sprintf("UPDATE users SET hospital=60, hospreason='Beaten badly in the battlearena', hp=0 WHERE userid=%u", $ht['userid']); $db->query($qry);}} $qry=sprintf("UPDATE battlearena SET p1=0, p2=0, p3=0, p4=0, p5=0, p6=0, p7=0, p8=0, p9=0, p10=0, p1b=0, p2b=0, p3b=0, p4b=0, p5b=0, p6b=0, p7b=0, p8b=0, p9b=0, p10b=0, lastwinner='%s', lastwinner2='%s', lastwinner3='%s', log='%s', bets='%d', split='%d', ready=0 WHERE batid='%u'", $lw, $lw2, $lw3, $z, $hw, $bz, $mop); $db->query($qry); echo sprintf("<font color=white>The battle has started. Go [url='battlearena.php?action=watch&a=%d']Here[/url] to watch", $mop); die(""); } else { include "attack3.php"; } ?> Quote Link to comment Share on other sites More sharing options...
Jeff.S Posted October 2, 2009 Share Posted October 2, 2009 Hi Nicholas, Not going to bother reading the whole script as there allot there but you are getting the error because the $db variable has not been set as the database class (e.g. $db = new database;). This is all done for you in globals.php (if this is V2 and if i remember Mccodes file settings) or global_func.php in V1 (i think) If i am right with that then you need to add something like: require_once("globals.php"); directly after the <?php Note: There may be some other stuff to go with this but i have not used Mccodes in a long time, so check your other files and find the top part thats the same on every file and add that to the top of the page. Note 2: I have not read the full code but if this is a cron and you add what i said above, it will not work, so let me know if it is and i will change my advice. Note 3: Im half a sleep when writing this and IE8 is realy, realy bad. Hope this helps :thumbsup: Quote Link to comment Share on other sites More sharing options...
CrazyT Posted October 2, 2009 Share Posted October 2, 2009 [warnbox] Just ask the question, if you have one. No need to try and mock him at the same time. [/warnbox] Why have you got that many queries? Quote Link to comment Share on other sites More sharing options...
Nicholas Posted October 3, 2009 Author Share Posted October 3, 2009 damn thats right the stupid include "globals.php"; or require_once "globals.php"; i forgot to add that lol, i dont get the error anymore on the page, so hopefully this mod will work now :) thx The_Past, easy thing to forget i guess tho lol. Quote Link to comment Share on other sites More sharing options...
Jeff.S Posted October 3, 2009 Share Posted October 3, 2009 thx The_Past, easy thing to forget i guess tho lol.We've all done that at some point ;) Quote Link to comment Share on other sites More sharing options...
Nicholas Posted October 3, 2009 Author Share Posted October 3, 2009 lol damn now i get this error when i try and start the battle lol. Fatal error: Cannot redeclare money_formatter() (previously declared in /_____/_____/_____/global_func.php:2) in /_____/_____/_____/global_func.php on line 5 this mod is getting on my nerves now lol. google doesnt help much when trying to find out how to fix these fatal errors lol. if i edit money_formatter() in global_func.php, it wont how how much cash you got in menu part on left lol. so i have no idea what to do... Quote Link to comment Share on other sites More sharing options...
Nicholas Posted October 3, 2009 Author Share Posted October 3, 2009 if i remove the include "globals.php"; on the file above that im having problems with i wont get the fatel error on the mod, but then i get the error on the mod up top again, any ideas why? Quote Link to comment Share on other sites More sharing options...
Danny696 Posted October 3, 2009 Share Posted October 3, 2009 Nicholas, im pritty sure you didnt make this. :| Quote Link to comment Share on other sites More sharing options...
Jeff.S Posted October 3, 2009 Share Posted October 3, 2009 Try using: include_once "globals.php"; Instead of: include "globals.php" Sounds like you got it including globals.php more than once, include_once() ; will not include the file if it has already been included. Quote Link to comment Share on other sites More sharing options...
Nicholas Posted October 3, 2009 Author Share Posted October 3, 2009 Nicholas, im pritty sure you didnt make this. :|i didnt say i made this lol. did i? Quote Link to comment Share on other sites More sharing options...
Nicholas Posted October 3, 2009 Author Share Posted October 3, 2009 Try using: include_once "globals.php"; Instead of: include "globals.php" Sounds like you got it including globals.php more than once, include_once() ; will not include the file if it has already been included. that was the reason lol thx include_once "globals.php"; dont get error on nither that files now, so hopefully it will work now. :) Quote Link to comment Share on other sites More sharing options...
Danny696 Posted October 3, 2009 Share Posted October 3, 2009 Nicholas, im pritty sure you didnt make this. :|i didnt say i made this lol. did i? So whos is this, and do you have there permission to post it? [warnbox]The member asked help on a problem , final verbal warning Danny be respectfull and helpfull towards members[/warnbox] Quote Link to comment Share on other sites More sharing options...
Nicholas Posted October 3, 2009 Author Share Posted October 3, 2009 Nicholas, im pritty sure you didnt make this. :|i didnt say i made this lol. did i? So whos is this, and do you have there permission to post it? [warnbox]The member asked help on a problem , final verbal warning Danny be respectfull and helpfull towards members[/warnbox] its not the full mod, there is like 3-5 files connected to this mod. this was the only file that had a error on it. 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.