Ekidd Posted May 30, 2007 Posted May 30, 2007 every time i click on item market this appears Fatal error: Cannot redeclare item_remove() in /www/007webpro.com/e/k/i/ekidd/htdocs/global_func.php on line 323 wat do i do btw i am usin mccodes v2 Quote
pspotential Posted May 30, 2007 Posted May 30, 2007 Re: i nd help with my item market replace all the code in yout itemmarket.php with this one and it should work <?php include "globals.php"; print "<h3>Item Market</h3>"; switch($_GET['action']) { case "buy": item_buy(); break; case "gift1": item_gift1(); break; case "gift2": item_gift2(); break; case "remove": item_remove(); break; default: imarket_index(); break; } function imarket_index() { global $db,$ir,$c,$userid,$h; print "Viewing all listings... <table width=75% cellspacing=1 class='table'> <tr style='background:gray'> <th>Adder</th> <th>Item</th> <th>Price</th> <th>Links</th> </tr>"; $q=$db->query("SELECT im.*, i.*, u.*,it.* FROM itemmarket im LEFT JOIN items i ON im.imITEM=i.itmid LEFT JOIN users u ON u.userid=im.imADDER LEFT JOIN itemtypes it ON i.itmtype=it.itmtypeid ORDER BY i.itmtype, i.itmname ASC"); $lt=""; while($r=$db->fetch_row($q)) { if($lt!=$r['itmtypename']) { $lt=$r['itmtypename']; print "\n<tr style='background: gray;'><th colspan=4>{$lt}</th></tr>"; } if($r['imCURRENCY']=="money") { $price="\$".number_format($r['imPRICE']); } else { $price=number_format($r['imPRICE'])." crystals"; } if($r['imADDER'] == $userid) { $link = "[[url='itemmarket.php?action=remove&ID={$r[']Remove[/url]]"; } else { $link = "[[url='itemmarket.php?action=buy&ID={$r[']Buy[/url]] [[url='itemmarket.php?action=gift1&ID={$r[']Gift[/url]]"; } print "\n<tr> <td>[url='viewuser.php?u={$r[']{$r['username']}[/url] [{$r['userid']}]</td> <td>{$r['itmname']}</td> <td>$price</td> <td>[[url='iteminfo.php?ID={$r[']Info[/url]] $link</td> </tr>"; } print "</table>"; } function item_buy() { global $db,$ir,$c,$userid,$h; $q=$db->query("SELECT * FROM itemmarket im LEFT JOIN items i ON i.itmid=im.imITEM WHERE imID={$_GET['ID']}",$c); if(!$db->num_rows($q)) { print "Error, either this item does not exist, or it has already been bought. [url='itemmarket.php']> Back[/url]"; $h->endpage(); exit; } $r=$db->fetch_row($q); $curr=$r['imCURRENCY']; if($r['imPRICE'] > $ir[$curr]) { print "Error, you do not have the funds to buy this item. [url='itemmarket.php']> Back[/url]"; $h->endpage(); exit; } item_add($userid, $r['imITEM'], 1); $i=($db->insert_id()) ? $db->insert_id() : 99999; $db->query("DELETE FROM itemmarket WHERE imID={$_GET['ID']}"); $db->query("UPDATE users SET $curr=$curr-{$r['imPRICE']} where userid=$userid"); $db->query("UPDATE users SET $curr=$curr+{$r['imPRICE']} where userid={$r['imADDER']}"); if($curr=="money") { event_add($r['imADDER'],"[url='viewuser.php?u=$userid']{$ir['username']}[/url] bought your {$r['itmname']} item from the market for \$".number_format($r['imPRICE']).".",$c); $db->query("INSERT INTO imbuylogs VALUES ('', {$r['imITEM']}, {$r['imADDER']}, $userid, {$r['imPRICE']}, {$r['imID']}, $i, unix_timestamp(), '{$ir['username']} bought a {$r['itmname']} from the item market for \${$r['imPRICE']} from user ID {$r['imADDER']}')"); print "You bought the {$r['itmname']} from the market for \$".number_format($r['imPRICE'])."."; } else { event_add($r['imADDER'],"[url='viewuser.php?u=$userid']{$ir['username']}[/url] bought your {$r['itmname']} item from the market for ".number_format($r['imPRICE'])." crystals.",$c); $db->query("INSERT INTO imbuylogs VALUES ('', {$r['imITEM']}, {$r['imADDER']}, $userid, {$r['imPRICE']}, {$r['imID']}, $i, unix_timestamp(), '{$ir['username']} bought a {$r['itmname']} from the item market for {$r['imPRICE']} crystals from user ID {$r['imADDER']}')"); print "You bought the {$r['itmname']} from the market for ".number_format($r['imPRICE'])." crystals."; } } function item_gift1() { global $db,$ir,$c,$userid,$h; $q=$db->query("SELECT * FROM itemmarket im LEFT JOIN items i ON i.itmid=im.imITEM WHERE imID={$_GET['ID']}"); if(!$db->num_rows($q)) { print "Error, either this item does not exist, or it has already been bought. [url='itemmarket.php']> Back[/url]"; $h->endpage(); exit; } $r=$db->fetch_row($q); $curr=$r['imCURRENCY']; if($r['imPRICE'] > $ir[$curr]) { print "Error, you do not have the funds to buy this item. [url='itemmarket.php']> Back[/url]"; $h->endpage(); exit; } if($curr=="money") { print "Buying the [b]{$r['itmname']}[/b] for \$".number_format($r['imPRICE'])." as a gift... <form action='itemmarket.php?action=gift2' method='post'> <input type='hidden' name='ID' value='{$_GET['ID']}' /> User to give gift to: ".user_dropdown($c,'user')." <input type='submit' value='Buy Item and Send Gift' /></form>"; } else { print "Buying the [b]{$r['itmname']}[/b] for ".number_format($r['imPRICE'])." crystals as a gift... <form action='itemmarket.php?action=gift2' method='post'> <input type='hidden' name='ID' value='{$_GET['ID']}' /> User to give gift to: ".user_dropdown($c,'user')." <input type='submit' value='Buy Item and Send Gift' /></form>"; } } function item_gift2() { global $db,$ir,$c,$userid,$h; $q=$db->query("SELECT * FROM itemmarket im LEFT JOIN items i ON i.itmid=im.imITEM WHERE imID={$_POST['ID']}"); if(!$db->num_rows($q)) { print "Error, either this item does not exist, or it has already been bought. [url='itemmarket.php']> Back[/url]"; $h->endpage(); exit; } $r=$db->fetch_row($q); $curr=$r['imCURRENCY']; if($r['imPRICE'] > $ir[$curr]) { print "Error, you do not have the funds to buy this item. [url='itemmarket.php']> Back[/url]"; $h->endpage(); exit; } item_add($_POST['user'], $r['imITEM'], 1); $i=($db->insert_id()) ? $db->insert_id() : 99999; $db->query("DELETE FROM itemmarket WHERE imID={$_POST['ID']}"); $db->query("UPDATE users SET $curr=$curr-{$r['imPRICE']} where userid=$userid"); $db->query("UPDATE users SET $curr=$curr+{$r['imPRICE']} where userid={$r['imADDER']}"); if($curr=="money") { event_add($r['imADDER'],"[url='viewuser.php?u=$userid']{$ir['username']}[/url] bought your {$r['itmname']} item from the market for \$".number_format($r['imPRICE']).".",$c); event_add($_POST['user'], "[url='viewuser.php?u=$userid']{$ir['username']}[/url] bought you a {$r['itmname']} from the item market as a gift.",$c); $u=$db->query("SELECT username FROM users WHERE userid={$_POST['user']}"); $uname=$db->fetch_single($u); $db->query("INSERT INTO imbuylogs VALUES ('', {$r['imITEM']}, {$r['imADDER']}, $userid, {$r['imPRICE']}, {$r['imID']}, $i, unix_timestamp(), '{$ir['username']} bought a {$r['itmname']} from the item market for \${$r['imPRICE']} from user ID {$r['imADDER']} as a gift for $uname [{$_POST['user']}]')"); print "You bought the {$r['itmname']} from the market for \$".number_format($r['imPRICE'])." and sent the gift to $uname."; } else { event_add($r['imADDER'],"[url='viewuser.php?u=$userid']{$ir['username']}[/url] bought your {$r['itmname']} item from the market for ".number_format($r['imPRICE'])." crystals.",$c); event_add($_POST['user'], "[url='viewuser.php?u=$userid']{$ir['username']}[/url] bought you a {$r['itmname']} from the item market as a gift.",$c); $u=$db->query("SELECT username FROM users WHERE userid={$_POST['user']}"); $uname=$db->fetch_single($u); $db->query("INSERT INTO imbuylogs VALUES ('', {$r['imITEM']}, {$r['imADDER']}, $userid, {$r['imPRICE']}, {$r['imID']}, $i, unix_timestamp(), '{$ir['username']} bought a {$r['itmname']} from the item market for {$r['imPRICE']} crystals from user ID {$r['imADDER']} as a gift for $uname [{$_POST['user']}]')"); print "You bought the {$r['itmname']} from the market for ".number_format($r['imPRICE'])." crystals and sent the gift to $uname."; } } $h->endpage(); ?> Quote
bamaman Posted June 7, 2007 Posted June 7, 2007 Re: i nd help with my item market Very new and learning here so bear with me..... changed my item market page to read as previously posted this is the error I get: Warning: Missing argument 1 for item_remove() in /home/bamaman/public_html/global_func.php on line 323 Warning: Missing argument 2 for item_remove() in /home/bamaman/public_html/global_func.php on line 323 Warning: Missing argument 3 for item_remove() in /home/bamaman/public_html/global_func.php on line 323 QUERY ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND inv_itmid=' at line 1 Query was SELECT * FROM inventory WHERE inv_userid= AND inv_itmid= and this is line 321-325 on my global_func.php: 321. } 322. function item_remove($user, $itemid, $qty) 323. { 324. global $db; 325. $q=$db->query("SELECT * FROM inventory WHERE inv_userid={$user} AND inv_itmid={$itmid}"); Quote
hamster01 Posted June 7, 2007 Posted June 7, 2007 Re: i nd help with my item market try: 321. } 322. function item_remove($user, $itemid, $qty) 323. { 324. global $db; 325. $q=$db->query("SELECT * FROM inventory WHERE inv_userid='$user' AND inv_itmid='$itmid'"); Quote
bamaman Posted June 7, 2007 Posted June 7, 2007 Re: i nd help with my item market this is still showing up when I try to remove an item Warning: Missing argument 1 for item_remove() in /home/bamaman/public_html/global_func.php on line 323 Warning: Missing argument 2 for item_remove() in /home/bamaman/public_html/global_func.php on line 323 Warning: Missing argument 3 for item_remove() in /home/bamaman/public_html/global_func.php on line 323 QUERY ERROR: Unknown column 'inv_itmid' in 'where clause' Query was SELECT * FROM inventory WHERE inv_userid='' AND inv_itmid='' Quote
hamster01 Posted June 7, 2007 Posted June 7, 2007 Re: i nd help with my item market thne try: 321. } 322. function item_remove($userid, $itemid, $qty) 323. { 324. global $db; 325. $q=$db->query("SELECT * FROM inventory WHERE inv_userid='$userid' AND inv_itmid='$itemid'"); this is still showing up when I try to remove an item Warning: Missing argument 1 for item_remove() in /home/bamaman/public_html/global_func.php on line 323 Warning: Missing argument 2 for item_remove() in /home/bamaman/public_html/global_func.php on line 323 Warning: Missing argument 3 for item_remove() in /home/bamaman/public_html/global_func.php on line 323 QUERY ERROR: Unknown column 'inv_itmid' in 'where clause' Query was SELECT * FROM inventory WHERE inv_userid='' AND inv_itmid='' Quote
bamaman Posted June 7, 2007 Posted June 7, 2007 Re: i nd help with my item market get what your are doing mine works with line 325 as 325. $q=$db->query("SELECT * FROM inventory WHERE inv_userid='$userid' AND inv_itemid='$itmid'"); but I am still gettting Warning: Missing argument 1 for item_remove() in /home/bamaman/public_html/global_func.php on line 323 Warning: Missing argument 2 for item_remove() in /home/bamaman/public_html/global_func.php on line 323 Warning: Missing argument 3 for item_remove() in /home/bamaman/public_html/global_func.php on line 323 Quote
hamster01 Posted June 7, 2007 Posted June 7, 2007 Re: i nd help with my item market Can you please post the whole script? Quote
bamaman Posted June 7, 2007 Posted June 7, 2007 Re: i nd help with my item market appreciate the help Deathstar does anyone else know where this would be coming form Warning: Missing argument 1 for item_remove() in /home/bamaman/public_html/global_func.php on line 323 Warning: Missing argument 2 for item_remove() in /home/bamaman/public_html/global_func.php on line 323 Warning: Missing argument 3 for item_remove() in /home/bamaman/public_html/global_func.php on line 323 Quote
pspotential Posted June 7, 2007 Posted June 7, 2007 Re: i nd help with my item market ok try replacing all code itemmarket.php <?php include "globals.php"; print "<h3>Item Market</h3>"; switch($_GET['action']) { case "buy": item_buy(); break; case "gift1": item_gift1(); break; case "gift2": item_gift2(); break; case "remove": item_remove(); break; default: imarket_index(); break; } function imarket_index() { global $db,$ir,$c,$userid,$h; print "Viewing all listings... <table width=75% cellspacing=1 class='table'> <tr style='background:gray'> <th>Adder</th> <th>Item</th> <th>Price</th> <th>Links</th> </tr>"; $q=$db->query("SELECT im.*, i.*, u.*,it.* FROM itemmarket im LEFT JOIN items i ON im.imITEM=i.itmid LEFT JOIN users u ON u.userid=im.imADDER LEFT JOIN itemtypes it ON i.itmtype=it.itmtypeid ORDER BY i.itmtype, i.itmname ASC"); $lt=""; while($r=$db->fetch_row($q)) { if($lt!=$r['itmtypename']) { $lt=$r['itmtypename']; print "\n<tr style='background: gray;'><th colspan=4>{$lt}</th></tr>"; } if($r['imCURRENCY']=="money") { $price="\$".number_format($r['imPRICE']); } else { $price=number_format($r['imPRICE'])." crystals"; } if($r['imADDER'] == $userid) { $link = "[[url='itemmarket.php?action=remove&ID={$r[']Remove[/url]]"; } else { $link = "[[url='itemmarket.php?action=buy&ID={$r[']Buy[/url]] [[url='itemmarket.php?action=gift1&ID={$r[']Gift[/url]]"; } print "\n<tr> <td>[url='viewuser.php?u={$r[']{$r['username']}[/url] [{$r['userid']}]</td> <td>{$r['itmname']}</td> <td>$price</td> <td>[[url='iteminfo.php?ID={$r[']Info[/url]] $link</td> </tr>"; } print "</table>"; } function item_buy() { global $db,$ir,$c,$userid,$h; $q=$db->query("SELECT * FROM itemmarket im LEFT JOIN items i ON i.itmid=im.imITEM WHERE imID={$_GET['ID']}",$c); if(!$db->num_rows($q)) { print "Error, either this item does not exist, or it has already been bought. [url='itemmarket.php']> Back[/url]"; $h->endpage(); exit; } $r=$db->fetch_row($q); $curr=$r['imCURRENCY']; if($r['imPRICE'] > $ir[$curr]) { print "Error, you do not have the funds to buy this item. [url='itemmarket.php']> Back[/url]"; $h->endpage(); exit; } item_add($userid, $r['imITEM'], 1); $i=($db->insert_id()) ? $db->insert_id() : 99999; $db->query("DELETE FROM itemmarket WHERE imID={$_GET['ID']}"); $db->query("UPDATE users SET $curr=$curr-{$r['imPRICE']} where userid=$userid"); $db->query("UPDATE users SET $curr=$curr+{$r['imPRICE']} where userid={$r['imADDER']}"); if($curr=="money") { event_add($r['imADDER'],"[url='viewuser.php?u=$userid']{$ir['username']}[/url] bought your {$r['itmname']} item from the market for \$".number_format($r['imPRICE']).".",$c); $db->query("INSERT INTO imbuylogs VALUES ('', {$r['imITEM']}, {$r['imADDER']}, $userid, {$r['imPRICE']}, {$r['imID']}, $i, unix_timestamp(), '{$ir['username']} bought a {$r['itmname']} from the item market for \${$r['imPRICE']} from user ID {$r['imADDER']}')"); print "You bought the {$r['itmname']} from the market for \$".number_format($r['imPRICE'])."."; } else { event_add($r['imADDER'],"[url='viewuser.php?u=$userid']{$ir['username']}[/url] bought your {$r['itmname']} item from the market for ".number_format($r['imPRICE'])." crystals.",$c); $db->query("INSERT INTO imbuylogs VALUES ('', {$r['imITEM']}, {$r['imADDER']}, $userid, {$r['imPRICE']}, {$r['imID']}, $i, unix_timestamp(), '{$ir['username']} bought a {$r['itmname']} from the item market for {$r['imPRICE']} crystals from user ID {$r['imADDER']}')"); print "You bought the {$r['itmname']} from the market for ".number_format($r['imPRICE'])." crystals."; } } function item_gift1() { global $db,$ir,$c,$userid,$h; $q=$db->query("SELECT * FROM itemmarket im LEFT JOIN items i ON i.itmid=im.imITEM WHERE imID={$_GET['ID']}"); if(!$db->num_rows($q)) { print "Error, either this item does not exist, or it has already been bought. [url='itemmarket.php']> Back[/url]"; $h->endpage(); exit; } $r=$db->fetch_row($q); $curr=$r['imCURRENCY']; if($r['imPRICE'] > $ir[$curr]) { print "Error, you do not have the funds to buy this item. [url='itemmarket.php']> Back[/url]"; $h->endpage(); exit; } if($curr=="money") { print "Buying the [b]{$r['itmname']}[/b] for \$".number_format($r['imPRICE'])." as a gift... <form action='itemmarket.php?action=gift2' method='post'> <input type='hidden' name='ID' value='{$_GET['ID']}' /> User to give gift to: ".user_dropdown($c,'user')." <input type='submit' value='Buy Item and Send Gift' /></form>"; } else { print "Buying the [b]{$r['itmname']}[/b] for ".number_format($r['imPRICE'])." crystals as a gift... <form action='itemmarket.php?action=gift2' method='post'> <input type='hidden' name='ID' value='{$_GET['ID']}' /> User to give gift to: ".user_dropdown($c,'user')." <input type='submit' value='Buy Item and Send Gift' /></form>"; } } function item_gift2() { global $db,$ir,$c,$userid,$h; $q=$db->query("SELECT * FROM itemmarket im LEFT JOIN items i ON i.itmid=im.imITEM WHERE imID={$_POST['ID']}"); if(!$db->num_rows($q)) { print "Error, either this item does not exist, or it has already been bought. [url='itemmarket.php']> Back[/url]"; $h->endpage(); exit; } $r=$db->fetch_row($q); $curr=$r['imCURRENCY']; if($r['imPRICE'] > $ir[$curr]) { print "Error, you do not have the funds to buy this item. [url='itemmarket.php']> Back[/url]"; $h->endpage(); exit; } item_add($_POST['user'], $r['imITEM'], 1); $i=($db->insert_id()) ? $db->insert_id() : 99999; $db->query("DELETE FROM itemmarket WHERE imID={$_POST['ID']}"); $db->query("UPDATE users SET $curr=$curr-{$r['imPRICE']} where userid=$userid"); $db->query("UPDATE users SET $curr=$curr+{$r['imPRICE']} where userid={$r['imADDER']}"); if($curr=="money") { event_add($r['imADDER'],"[url='viewuser.php?u=$userid']{$ir['username']}[/url] bought your {$r['itmname']} item from the market for \$".number_format($r['imPRICE']).".",$c); event_add($_POST['user'], "[url='viewuser.php?u=$userid']{$ir['username']}[/url] bought you a {$r['itmname']} from the item market as a gift.",$c); $u=$db->query("SELECT username FROM users WHERE userid={$_POST['user']}"); $uname=$db->fetch_single($u); $db->query("INSERT INTO imbuylogs VALUES ('', {$r['imITEM']}, {$r['imADDER']}, $userid, {$r['imPRICE']}, {$r['imID']}, $i, unix_timestamp(), '{$ir['username']} bought a {$r['itmname']} from the item market for \${$r['imPRICE']} from user ID {$r['imADDER']} as a gift for $uname [{$_POST['user']}]')"); print "You bought the {$r['itmname']} from the market for \$".number_format($r['imPRICE'])." and sent the gift to $uname."; } else { event_add($r['imADDER'],"[url='viewuser.php?u=$userid']{$ir['username']}[/url] bought your {$r['itmname']} item from the market for ".number_format($r['imPRICE'])." crystals.",$c); event_add($_POST['user'], "[url='viewuser.php?u=$userid']{$ir['username']}[/url] bought you a {$r['itmname']} from the item market as a gift.",$c); $u=$db->query("SELECT username FROM users WHERE userid={$_POST['user']}"); $uname=$db->fetch_single($u); $db->query("INSERT INTO imbuylogs VALUES ('', {$r['imITEM']}, {$r['imADDER']}, $userid, {$r['imPRICE']}, {$r['imID']}, $i, unix_timestamp(), '{$ir['username']} bought a {$r['itmname']} from the item market for {$r['imPRICE']} crystals from user ID {$r['imADDER']} as a gift for $uname [{$_POST['user']}]')"); print "You bought the {$r['itmname']} from the market for ".number_format($r['imPRICE'])." crystals and sent the gift to $uname."; } } $h->endpage(); ?> Quote
pspotential Posted June 7, 2007 Posted June 7, 2007 Re: i nd help with my item market global_func.php <?php function money_formatter($muny,$symb='$') { return $symb.number_format($muny); } function itemtype_dropdown($connection,$ddname="item_type",$selected=-1) { global $db; $ret="<select name='$ddname' type='dropdown'>"; $q=$db->query("SELECT * FROM itemtypes ORDER BY itmtypename ASC"); if($selected == -1) { $first=0; } else { $first=1; } while($r=$db->fetch_row($q)) { $ret.="\n<option value='{$r['itmtypeid']}'"; if ($selected == $r['itmtypeid'] || $first == 0) { $ret.=" selected='selected'";$first=1; } $ret.=">{$r['itmtypename']}</option>"; } $ret.="\n</select>"; return $ret; } function item_dropdown($connection,$ddname="item",$selected=-1) { global $db; $ret="<select name='$ddname' type='dropdown'>"; $q=$db->query("SELECT * FROM items ORDER BY itmname ASC"); if($selected == -1) { $first=0; } else { $first=1; } while($r=$db->fetch_row($q)) { $ret.="\n<option value='{$r['itmid']}'"; if ($selected == $r['itmid'] || $first == 0) { $ret.=" selected='selected'";$first=1; } $ret.=">{$r['itmname']}</option>"; } $ret.="\n</select>"; return $ret; } function item2_dropdown($connection,$ddname="item",$selected=-1) { global $db; $ret="<select name='$ddname' type='dropdown'>"; $q=$db->query("SELECT * FROM items ORDER BY itmname ASC"); if($selected < 1) { $ret.="<option value='0' selected='selected'>-- None --</option>"; } else { $ret.="<option value='0'>-- None --</option>"; } while($r=$db->fetch_row($q)) { $ret.="\n<option value='{$r['itmid']}'"; if ($selected == $r['itmid']) { $ret.=" selected='selected'";$first=1; } $ret.=">{$r['itmname']}</option>"; } $ret.="\n</select>"; return $ret; } function location_dropdown($connection,$ddname="location",$selected=-1) { global $db; $ret="<select name='$ddname' type='dropdown'>"; $q=$db->query("SELECT * FROM cities ORDER BY cityname ASC"); if($selected == -1) { $first=0; } else { $first=1; } while($r=$db->fetch_row($q)) { $ret.="\n<option value='{$r['cityid']}'"; if ($selected == $r['cityid'] || $first == 0) { $ret.=" selected='selected'";$first=1; } $ret.= ">{$r['cityname']}</option>"; } $ret.="\n</select>"; return $ret; } function shop_dropdown($connection,$ddname="shop",$selected=-1) { global $db; $ret="<select name='$ddname' type='dropdown'>"; $q=$db->query("SELECT * FROM shops ORDER BY shopNAME ASC"); if($selected == -1) { $first=0; } else { $first=1; } while($r=$db->fetch_row($q)) { $ret.="\n<option value='{$r['shopID']}'"; if ($selected == $r['shopID'] || $first == 0) { $ret.=" selected='selected'";$first=1; } $ret.= ">{$r['shopNAME']}</option>"; } $ret.="\n</select>"; return $ret; } function user_dropdown($connection,$ddname="user",$selected=-1) { global $db; $ret="<select name='$ddname' type='dropdown'>"; $q=$db->query("SELECT * FROM users ORDER BY username ASC"); if($selected == -1) { $first=0; } else { $first=1; } while($r=$db->fetch_row($q)) { $ret.="\n<option value='{$r['userid']}'"; if ($selected == $r['userid'] || $first == 0) { $ret.=" selected='selected'";$first=1; } $ret.= ">{$r['username']}</option>"; } $ret.="\n</select>"; return $ret; } function challengebot_dropdown($connection,$ddname="bot",$selected=-1) { global $db; $ret="<select name='$ddname' type='dropdown'>"; $q=$db->query("SELECT cb.*,u.* FROM challengebots AS cb LEFT JOIN users AS u ON cb.cb_npcid=u.userid ORDER BY u.username ASC"); if($selected == -1) { $first=0; } else { $first=1; } while($r=$db->fetch_row($q)) { $ret.="\n<option value='{$r['userid']}'"; if ($selected == $r['userid'] || $first == 0) { $ret.=" selected='selected'";$first=1; } $ret.= ">{$r['username']}</option>"; } $ret.="\n</select>"; return $ret; } function fed_user_dropdown($connection,$ddname="user",$selected=-1) { global $db; $ret="<select name='$ddname' type='dropdown'>"; $q=$db->query("SELECT * FROM users WHERE fedjail=1 ORDER BY username ASC"); if($selected == -1) { $first=0; } else { $first=1; } while($r=$db->fetch_row($q)) { $ret.="\n<option value='{$r['userid']}'"; if ($selected == $r['userid'] || $first == 0) { $ret.=" selected='selected'";$first=1; } $ret.= ">{$r['username']}</option>"; } $ret.="\n</select>"; return $ret; } function mailb_user_dropdown($connection,$ddname="user",$selected=-1) { global $db; $ret="<select name='$ddname' type='dropdown'>"; $q=$db->query("SELECT * FROM users WHERE mailban > 0 ORDER BY username ASC"); if($selected == -1) { $first=0; } else { $first=1; } while($r=$db->fetch_row($q)) { $ret.="\n<option value='{$r['userid']}'"; if ($selected == $r['userid'] || $first == 0) { $ret.=" selected='selected'";$first=1; } $ret.= ">{$r['username']}</option>"; } $ret.="\n</select>"; return $ret; } function forumb_user_dropdown($connection,$ddname="user",$selected=-1) { global $db; $ret="<select name='$ddname' type='dropdown'>"; $q=$db->query("SELECT * FROM users WHERE forumban > 0 ORDER BY username ASC"); if($selected == -1) { $first=0; } else { $first=1; } while($r=$db->fetch_row($q)) { $ret.="\n<option value='{$r['userid']}'"; if ($selected == $r['userid'] || $first == 0) { $ret.=" selected='selected'";$first=1; } $ret.= ">{$r['username']}</option>"; } $ret.="\n</select>"; return $ret; } function job_dropdown($connection,$ddname="job",$selected=-1) { global $db; $ret="<select name='$ddname' type='dropdown'>"; $q=$db->query("SELECT * FROM jobs ORDER BY jNAME ASC"); if($selected == -1) { $first=0; } else { $first=1; } while($r=$db->fetch_row($q)) { $ret.="\n<option value='{$r['jID']}'"; if ($selected == $r['jID'] || $first == 0) { $ret.=" selected='selected'";$first=1; } $ret.=">{$r['jNAME']}</option>"; } $ret.="\n</select>"; return $ret; } function jobrank_dropdown($connection,$ddname="jobrank",$selected=-1) { global $db; $ret="<select name='$ddname' type='dropdown'>"; $q=$db->query("SELECT jr.*,j.* FROM jobranks jr LEFT JOIN jobs j ON jr.jrJOB=j.jID ORDER BY j.jNAME ASC, jr.jrNAME ASC"); if($selected == -1) { $first=0; } else { $first=1; } while($r=$db->fetch_row($q)) { $ret.="\n<option value='{$r['jrID']}'"; if ($selected == $r['jrID'] || $first == 0) { $ret.=" selected='selected'";$first=1; } $ret.=">{$r['jNAME']} - {$r['jrNAME']}</option>"; } $ret.="\n</select>"; return $ret; } function house_dropdown($connection,$ddname="house",$selected=-1) { global $db; $ret="<select name='$ddname' type='dropdown'>"; $q=$db->query("SELECT * FROM houses ORDER BY hNAME ASC"); if($selected == -1) { $first=0; } else { $first=1; } while($r=$db->fetch_row($q)) { $ret.="\n<option value='{$r['hID']}'"; if ($selected == $r['hID'] || $first == 0) { $ret.=" selected='selected'";$first=1; } $ret.=">{$r['hNAME']}</option>"; } $ret.="\n</select>"; return $ret; } function house2_dropdown($connection,$ddname="house",$selected=-1) { global $db; $ret="<select name='$ddname' type='dropdown'>"; $q=$db->query("SELECT * FROM houses ORDER BY hNAME ASC"); if($selected == -1) { $first=0; } else { $first=1; } while($r=$db->fetch_row($q)) { $ret.="\n<option value='{$r['hWILL']}'"; if ($selected == $r['hWILL'] || $first == 0) { $ret.=" selected='selected'";$first=1; } $ret.=">{$r['hNAME']}</option>"; } $ret.="\n</select>"; return $ret; } function course_dropdown($connection,$ddname="course",$selected=-1) { global $db; $ret="<select name='$ddname' type='dropdown'>"; $q=$db->query("SELECT * FROM courses ORDER BY crNAME ASC"); if($selected == -1) { $first=0; } else { $first=1; } while($r=$db->fetch_row($q)) { $ret.="\n<option value='{$r['crID']}'"; if ($selected == $r['crID'] || $first == 0) { $ret.=" selected='selected'";$first=1; } $ret.=">{$r['crNAME']}</option>"; } $ret.="\n</select>"; return $ret; } function crime_dropdown($connection,$ddname="crime",$selected=-1) { global $db; $ret="<select name='$ddname' type='dropdown'>"; $q=$db->query("SELECT * FROM crimes ORDER BY crimeNAME ASC"); if($selected == -1) { $first=0; } else { $first=1; } while($r=$db->fetch_row($q)) { $ret.="\n<option value='{$r['crimeID']}'"; if ($selected == $r['crimeID'] || $first == 0) { $ret.=" selected='selected'";$first=1; } $ret.=">{$r['crimeNAME']}</option>"; } $ret.="\n</select>"; return $ret; } function crimegroup_dropdown($connection,$ddname="crimegroup",$selected=-1) { global $db; $ret="<select name='$ddname' type='dropdown'>"; $q=$db->query("SELECT * FROM crimegroups ORDER BY cgNAME ASC"); if($selected == -1) { $first=0; } else { $first=1; } while($r=$db->fetch_row($q)) { $ret.="\n<option value='{$r['cgID']}'"; if ($selected == $r['cgID'] || $first == 0) { $ret.=" selected='selected'";$first=1; } $ret.=">{$r['cgNAME']}</option>"; } $ret.="\n</select>"; return $ret; } function event_add($userid,$text,$connection=0) { global $db; $text=mysql_escape($text); $db->query("INSERT INTO events VALUES('',$userid,UNIX_TIMESTAMP(),0,'$text')"); $db->query("UPDATE users SET new_events=new_events+1 WHERE userid={$userid}"); return 1; } function mysql_escape($str) { return str_replace("'","''",$str); } function check_level() { global $db; global $ir,$c,$userid; $ir['exp_needed']=(int) (($ir['level']+1)*($ir['level']+1)*($ir['level']+1)*2.2); if($ir['exp'] >= $ir['exp_needed']) { $expu=$ir['exp']-$ir['exp_needed']; $ir['level']+=1; $ir['exp']=$expu; $ir['energy']+=2; $ir['brave']+=2; $ir['maxenergy']+=2; $ir['maxbrave']+=2; $ir['hp']+=50; $ir['maxhp']+=50; $ir['exp_needed']=(int) (($ir['level']+1)*($ir['level']+1)*($ir['level']+1)*2.2); $db->query("UPDATE users SET level=level+1,exp=$expu,energy=energy+2,brave=brave+2,maxenergy=maxenergy+2,maxbrave=maxbrave+2, hp=hp+50,maxhp=maxhp+50 where userid=$userid"); } } function get_rank($stat, $mykey) { global $db; global $ir,$userid,$c; $q=$db->query("SELECT count(*) FROM userstats us LEFT JOIN users u ON us.userid=u.userid WHERE us.$mykey > $stat AND us.userid != $userid AND u.user_level != 0") ; return $db->fetch_single($q)+1; } function item_add($user, $itemid, $qty, $notid=0) { global $db; if($notid > 0) { $q=$db->query("SELECT * FROM inventory WHERE inv_userid={$user} and inv_itemid={$itemid} AND inv_id != {$notid}"); } else { $q=$db->query("SELECT * FROM inventory WHERE inv_userid={$user} and inv_itemid={$itemid}"); } if($db->num_rows($q) > 0) { $r=$db->fetch_row($q); $db->query("UPDATE inventory SET inv_qty=inv_qty+{$qty} WHERE inv_id={$r['inv_id']}"); } else { $db->query("INSERT INTO inventory (inv_itemid, inv_userid, inv_qty) VALUES ({$itemid}, {$user}, {$qty})"); } } function item_remove($user, $itemid, $qty) { global $db; $q=$db->query("SELECT * FROM inventory WHERE inv_userid={$user} AND inv_itemid={$itemid}"); if($db->num_rows($q) > 0) { $r=$db->fetch_row($q); if($r['inv_qty']>$qty) { $db->query("UPDATE inventory SET inv_qty=inv_qty-{$qty} WHERE inv_id={$r['inv_id']}"); } else { $db->query("DELETE FROM inventory WHERE inv_id={$r['inv_id']}"); } } } function forum_dropdown($connection,$ddname="forum",$selected=-1) { global $db; $ret="<select name='$ddname' type='dropdown'>"; $q=$db->query("SELECT * FROM forum_forums ORDER BY ff_name ASC"); if($selected == -1) { $first=0; } else { $first=1; } while($r=$db->fetch_row($q)) { $ret.="\n<option value='{$r['ff_id']}'"; if ($selected == $r['ff_id'] || $first == 0) { $ret.=" selected='selected'";$first=1; } $ret.= ">{$r['ff_name']}</option>"; } $ret.="\n</select>"; return $ret; } function make_bigint($str, $positive=1) { $str = (string) $str; $ret = ""; for($i=0;$i<strlen($str);$i++) { if((ord($str[$i]) > 47 && ord($str[$i]) < 58) or ($str[$i]=="-" && $positive == 0)) { $ret.=$str[$i]; } } if(strlen($ret) == 0) { return "0"; } return $ret; } function stafflog_add($text) { global $db, $ir; $IP = ($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; $text=$db->escape($text); $db->query("INSERT INTO stafflog VALUES(NULL, {$ir['userid']}, unix_timestamp(), '$text', '$IP')"); } ?> 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.