bugsybunny Posted August 27, 2009 Posted August 27, 2009 howdy all, im having a massive problem with the propety market, when a member adds it for sale its fine, when some one buys it, its fine, BUT when the owner trys and removes it, it comes off the market, but it will give them a different property back, its driving me mad! any help ?? <?php include "globals.php"; print "<center><font size='4' face='Arial, Helvetica, sans-serif'>Property Market</font> "; switch($_GET['action']) { case "buy": buy_house(); break; case "remove": remove_house(); break; default: market_index(); break; } function market_index() { global $db,$ir,$c,$userid; print "<table width=90% cellspacing=1 class='table'> <tr> <th>Owner</th> <th>House</th> <th>Price</th> <th>Links</th> </tr>"; $q=$db->query("SELECT pr.*, h.*, u.* FROM propertymarket pr LEFT JOIN houses h ON prHOUSE=h.hID LEFT JOIN users u ON u.userid=pr.prOWNER ORDER BY pr.prCOST ASC",$c); $lt=""; while($r=$db->fetch_row($q)) { if($r['prOWNER'] == $userid) { $link = "[[url='propertymarket.php?action=remove&ID={$r[']Remove[/url]]"; } else { $link = "[[url='propertymarket.php?action=buy&ID={$r[']Buy[/url]]"; } $cost=money_formatter($r['prCOST']); print "<tr> <td>[url='viewuser.php?u={$r[']{$r['username']}[/url] [{$r['userid']}]</td> <td>{$r['hNAME']}</td> <td>$cost</td> <td>$link</td> </tr>"; } print "</table>"; } function remove_house() { global $db,$ir,$c,$userid,$h; $q=$db->query("SELECT pr.*, h.*, u.* FROM propertymarket pr LEFT JOIN houses h ON prHOUSE=h.hID LEFT JOIN users u ON u.userid=pr.prOWNER ORDER BY pr.prCOST ASC",$c); if(!$db->num_rows($q)) { print "Error, either this house does not exist, or you are not the owner. [url='propertymarket.php']> Back[/url]"; $h->endpage(); exit; } $r=$db->fetch_row($q); $db->query("INSERT INTO `properties` (`prID`, `prOWNER`, `prHOUSE`) VALUES ('NULL', '$userid', '{$r['hID']}');",$c); $db->query("DELETE FROM propertymarket WHERE prID={$_GET['ID']}",$c); print "House removed from market! [url='propertymarket.php']> Back[/url]"; } function buy_house() { global $db,$ir,$c,$userid,$h; $q=$db->query("SELECT pr.*, h.*, u.* FROM propertymarket pr LEFT JOIN houses h ON prHOUSE=h.hID LEFT JOIN users u ON u.userid=pr.prOWNER ORDER BY pr.prCOST ASC",$c); if(!$db->num_rows($q)) { print "Error, either this house does not exist, or it has already been sold. [url='propertymarket.php']> Back[/url]"; $h->endpage(); exit; } $r=$db->fetch_row($q); if($r['prCOST'] > $ir['money']) { print "Error, you do not have the funds to buy this house. [url='propertymarket.php']> Back[/url]"; $h->endpage(); exit; } $db->query("INSERT INTO `properties` (`prID`, `prOWNER`, `prHOUSE`) VALUES ('NULL', '$userid', '{$r['hID']}');",$c); event_add($r['prOWNER'],"[url='viewuser.php?u=$userid']{$ir['username']}[/url] bought your {$r['hNAME']} from the property market for {$r['prCOST']}.",$c); $db->query("DELETE FROM propertymarket WHERE prID={$_GET['ID']}",$c); print "You bought the {$r['hNAME']} from the market for \$".number_format($r['prCOST'])."."; } $h->endpage(); ?> thank you in advance Quote
bugsybunny Posted August 30, 2009 Author Posted August 30, 2009 Re: property market error Any advice guys? Quote
awakenedlands.com Posted September 2, 2009 Posted September 2, 2009 Re: property market error I assume players can only post 1 house on the market at a time, correct? If so, try changing your remove_house query to something more simple like the following: SELECT pr.* FROM propertymarket WHERE userid = $userid See if that fixes it. If they can post more than one house, you'll need to pass the prID field to select only that record. 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.