thebobby Posted January 23, 2011 Share Posted January 23, 2011 installed code all works except when u go to add item to auction it says error occured please try again.. Quote Link to comment Share on other sites More sharing options...
thebobby Posted January 23, 2011 Author Share Posted January 23, 2011 code <?php //Made by zeddicus, do NOT re-distribute. //Copyright 2010 include(DIRNAME(__FILE__).'/globals.php'); $_GET['page'] = isset($_GET['page']) ? trim($_GET['page']) : 'index'; switch($_GET['page']) { case 'index' : index(); break; case 'Bid' : Bid(); break; case 'Add' : Add(); break; default : index(); break; } function index() { global $h; $Data = mysql_query("SELECT g.`ID`,g.`SellerID`,g.`ItemID`,g.`Time`,g.`CurrentBid`,g.`BuyNow`,g.`TimeLeft`,i.`itmid`,i.`itmname` FROM `gAuction` g LEFT JOIN `items` i ON (g.`ItemID` = i.`itmid`)") or die(mysql_error()); echo (' <span style = "font-size:2em; font-family:Arial,Helvetica,sans-serif; color:#8B0000">Auction House</span> <hr width = "90%"> <table border = "0" class = "table" align = "center" width = "90%" style = "text-align:center" cellspacing = "1"> <tr> <th>Seller</th> <th>Item</th> <th>Time Left</th> <th>Current Bid</th> <th>Links</th> </tr>'); if(!mysql_num_rows($Data)) { echo ('<tr> <td colspan = "5">There are no auction being held at the present time.</td> </tr> </table>'); exit($h->endpage()); }else{ while($aData = mysql_fetch_array($Data)) { $time = $aData['Time'] - time() + $aData['TimeLeft']; echo (' <tr> <td>'.$aData['SellerID'].'</td> <td>'.stripslashes(htmlentities($aData['itmname'])).'</td> <td>'.time_format($time).'</td> <td width = "15%">$'.number_format($aData['CurrentBid']).'</td> <td width = "15%" align = "center"><a href = "auction.php?page=Bid&ID='.$aData['ID'].'"><span style = "color:#8B0000">Bid</span></a>|| <a href = "iteminfo.php?ID='.$aData['ItemID'].'"><span style = "color:#8B0000">Info</span></a></td>'); } echo ('</tr> </table> '); } $h->endpage(); } function Bid() { global $h,$ir; echo (' <span style = "font-size:2em; font-family:Arial,Helvetica,sans-serif; color:#8B0000">Bidding on Item</span> <hr width = "90%">'); $Data = mysql_query("SELECT g.`ID`,g.`SellerID`,g.`ItemID`,g.`CurrentBid`,g.`BuyNow`,g.`TimeLeft`,i.`itmid`,i.`itmname` FROM `gAuction` g LEFT JOIN `items` i ON (g.`ItemID` = i.`itmid`) WHERE (g.`ID` = ".abs(intval($_GET['ID'])).")") or die(mysql_error()); if(!mysql_num_rows($Data) || !ctype_digit($_GET['ID'])) { echo ('An error has occurred, please go back and try again.'); exit($h->endpage()); } $Data = mysql_fetch_array($Data); if((isset($_POST['bid']))) { if(!ctype_digit($_POST['bid'])) { echo ('An error has occurred, please try again.'); exit($h->endpage()); } if($_POST['bid'] < $Data['CurrentBid'] || $ir['money'] < $_POST['bid']) { echo ('You\'ve bidded below the current bid, or you don\'t have enough cash to bid. <a href = "/auction.php"><span style = "color:#8B0000">Go Back</span></a>'); exit($h->endpage()); } if($_POST['bid'] >= $Data['BuyNow'] && $Data['BuyNow'] > 0) { mysql_query("DELETE FROM `gAuction` WHERE (`ID` = ".abs(intval($_GET['ID'])).")"); //Auction Delete mysql_query("UPDATE `users` SET `money` = `money` - ".abs(intval($_POST['bid']))." WHERE (`userid` = ".$_SESSION['userid'].")"); //Take cash from user mysql_query("INSERT INTO `inventory` VALUES ('',".$Data['ItemID'].",".$_SESSION['userid'].",1)"); // Credit winner item event_add($Data['SellerID'],''.mysql_real_escape_string($ir['username']).' bought your item of the auction using your "Buy It Now Price" ($'.number_format($Data['BuyNow']).')'); mysql_query("UPDATE `users` SET `money` = `money` + ".abs(intval($_POST['bid']))." WHERE (`userid` = ".$Data['SellerID'].")"); //Give cash to user echo ('You\'ve successfully purchased the item from the Auction using the "Buy It Now" price!. <a href = "/index.php"><span style = "color:#8B0000">Go Home</span></a>'); }else{ mysql_query("UPDATE `gAuction` SET `CurrentBid` = ".abs(intval($_POST['bid']))." WHERE (`ID` = ".abs(intval($_GET['ID'])).")"); // mysql_query("INSERT INTO `gAuctionBids` VALUES ('',".$Data['ID'].",".$_SESSION['userid'].",".abs(intval($_POST['bid'])).")"); //insert bid mysql_query("UPDATE `users` SET `money` = `money` - ".abs(intval($_POST['bid']))." WHERE (`userid` = ".$_SESSION['userid'].")"); //Take cash from user echo ('Your bid has been confirmed. <a href = "/auction.php"><span style = "color:#8B0000">Back to Auction</span></a>'); } } if($Data['BuyNow'] == 0) { $Buy = 'Disabled by user'; }else{ $Buy = number_format($Data['BuyNow']); } if($Data['BuyNow'] == 0) { $Sign = ''; }else{ $Sign = '$'; } echo (' <table class = "table" cellspacing = "1" width = "35%" align = "center" style = "text-align:center"> <form action = "auction.php?page=Bid&ID='.$_GET['ID'].'" method = "post"> <tr> <td width = "25%">Item Name:</td> <td><span style = "color:#8B0000">'.htmlentities($Data['itmname']).'</span></td> </tr> <tr> <td width = "25%">Current Bid:</td> <td>'.number_format($Data['CurrentBid']).'</td> </tr> <tr> <td width = "25%">Buy Now Price:</td> <td>'.$Sign.''.$Buy.'</td> </tr> <tr> <td width = "25%">Enter Bid:</td> <td><input type = "text" name = "bid" value = "0" /></td> </tr> <tr> <td colspan = "2"><input type = "submit" value = "Place Bid" /></td> </tr> </form> </table> <a href = "/auction.php"><span style = "color:#8B0000">Go Back</a>'); $h->endpage(); } function Add() { global $h; $Data = mysql_query("SELECT i.`inv_itemid`,i.`inv_userid`,i.`inv_qty`,it.`itmid`,it.`itmname` FROM `inventory` i LEFT JOIN `items` it ON (i.`inv_itemid` = it.`itmid`) WHERE (`inv_userid` = ".$_SESSION['userid'].") AND (`inv_itemid` = ".abs(intval($_GET['ID'])).")") or die(mysql_error()); if(!mysql_num_rows($Data) || !ctype_digit($_GET['ID'])) { echo ('An error has occurred, please go back and try again.'); exit($h->endpage()); } $Data = mysql_fetch_array($Data); echo (' <span style = "font-size:2em; font-family:Arial,Helvetica,sans-serif; color:#8B0000">Adding Item To Auction</span> <hr width = "90%"> You have <span style = "color:#8B0000">'.number_format($Data['inv_qty']).'</span> - <span style = "color:#8B0000">'.htmlentities($Data['itmname']).'</span> <hr width = "90%">'); if((isset($_POST['time']))) { $One = mysql_query("SELECT `ID` FROM `gAuction` WHERE (`SellerID` = ".$_SESSION['userid'].")"); if(mysql_num_rows($One)) { echo ('Only one item at the auction please.'); exit($h->endpage()); } if(!in_array($_POST['time'], array('1Hour','6Hours','1Day','2Days'))) { echo ('An error has occured please go back and try again.'); exit($h->endpage()); } if($Data['inv_qty'] < 1) { echo ('It seems you don\'t have enough of this item to send it to auction.'); exit($h->endpage()); } if($_POST['time'] === '1Hour') { $time = '3600'; } elseif($_POST['time'] === '6Hours') { $time = '21600'; } elseif($_POST['time'] === '1Day') { $time = '86400'; } elseif($_POST['time'] === '2Days') { $time = '172800'; } mysql_query("INSERT INTO `gAuction` VALUES ('',".$_SESSION['userid'].",".$Data['itmid'].",".abs(intval($_POST['sbid'])).",".abs(intval($_POST['buy'])).",".$time.",unix_timestamp())") or die(mysql_error()); if($Data['inv_qty'] > 1) { mysql_query("UPDATE `inventory` SET `inv_qty` = `inv_qty` - 1 WHERE (`inv_userid` = ".$_SESSION['userid'].") AND (`inv_itemid` = ".$Data['itmid'].")") OR DIE(MYSQL_ERROR()); }else{ mysql_query("DELETE FROM `inventory` WHERE (`inv_userid` = ".$_SESSION['userid'].") AND (`inv_itemid` = ".$Data['itmid'].")")OR DIE(MYSQL_ERROR()); } echo ('You\'ve successfully add the item to the auction. <a href = "/auction.php"><span style = "color:#8B0000">Click here to View</span></a>'); }else{ echo (' <table border = "0" class = "table" cellspacing = "1" width = "60%" align = "center" style = "text-align:center"> <form action = "auction.php?page=Add&ID='.$_GET['ID'].'" method = "post"> <tr> <td colspan = "2">Select the amount off time you wish your auction to last.</td> </tr> <tr> <td colspan = "2">1 Hour<input type = "radio" name = "time" value = "1Hour" /> 6 Hours<input type = "radio" name = "time" value = "6Hours" /> 24 Hours<input type = "radio" name = "time" value = "1Day" /> 48 Hours<input type = "radio" name = "time" value = "2Days" /></td> </tr> <tr> <td>Starting Bid</td> <td><input type = "text" name = "sbid" value = "0" /></td> </tr> <tr> <td>Buy It Now Price:</td> <td><input type = "text" name = "buy" value = "0" />(Enter 0 to disable)</td> </tr> <tr> <td colspan = "2"><input type = "submit" value = "Add item to auction" /></td> </tr> </form> </table> <a href = "/inventory.php"><span style = "color:#8B0000">Go Back</span></a>'); } $h->endpage(); } ?> Quote Link to comment Share on other sites More sharing options...
thebobby Posted January 24, 2011 Author Share Posted January 24, 2011 any ideas by chance Quote Link to comment Share on other sites More sharing options...
Blade Maker Posted January 25, 2011 Share Posted January 25, 2011 One of the if statements are prob messed up, you could just ask me as I have been asking you. Quote Link to comment Share on other sites More sharing options...
Diesl Posted January 25, 2011 Share Posted January 25, 2011 You have 2 instances in your add() function that will give you that output. The first if(!mysql_num_rows($Data) || !ctype_digit($_GET['ID'])) { echo ('An error has occurred, please go back and try again.'); exit($h->endpage()); } The second if(!in_array($_POST['time'], array('1Hour','6Hours','1Day','2Days'))) { echo ('An error has occured please go back and try again.'); exit($h->endpage()); } First determine which one of these it is outputting to. Add giberish into one of the echos to see which one it is. If it's the first one, 2 possible scenarios. (1) mysql_num_rows is returning 0, which means it can not find a match for the selected item id in the items table or in the inventory table. (2) the ID being returned is a string that doesn't contain ALL integers. If its the second one, (3) $_POST['time'] has a value that is not in the array you defined here: array('1Hour','6Hours','1Day','2Days') My guess is that its most likely (1), but check those instances to be sure. Quote Link to comment Share on other sites More sharing options...
Equinox Posted January 25, 2011 Share Posted January 25, 2011 It's already been established that the 'fix all holes in mccodes' header code is the reason this doesn't work. /thread Quote Link to comment Share on other sites More sharing options...
Diesl Posted January 25, 2011 Share Posted January 25, 2011 It's already been established that the 'fix all holes in mccodes' header code is the reason this doesn't work. /thread Could you provide a link or reference to the thread that discusses this issue? Thanks. Quote Link to comment Share on other sites More sharing options...
iSOS Posted January 25, 2011 Share Posted January 25, 2011 Quoted from "Equinox" It's already been established that the 'fix all holes in mccodes' header code is the reason this doesn't work. /thread Could you provide a link or reference to the thread that discusses this issue? Thanks. I made it a long time ago and thats the problem. Quote Link to comment Share on other sites More sharing options...
thebobby Posted January 26, 2011 Author Share Posted January 26, 2011 this is where the error come froms function Add() { global $h; $Data = mysql_query("SELECT iv.`inv_itemid`,iv.`inv_userid`,iv.`inv_qty`,it.`itmid`,it.`itmname` FROM `inventory` iv LEFT JOIN `items` it ON (iv.`inv_itemid` = it.`itmid`) WHERE (`inv_userid` = ".$_SESSION['userid'].") AND (`inv_itemid` = ".abs(intval($_GET['ID'])).")") or die(mysql_error()); if(!mysql_num_rows($Data) || !ctype_digit($_GET['ID'])) { echo ('IamabitchAn error has occurred, please go back and try again.'); exit($h->endpage()); } $Data = mysql_fetch_array($Data); Quote Link to comment Share on other sites More sharing options...
Diesl Posted January 26, 2011 Share Posted January 26, 2011 function Add() { global $h; $Data = mysql_query("SELECT iv.`inv_itemid`,iv.`inv_userid`,iv.`inv_qty`,it.`itmid`,it.`itmname` FROM `inventory` iv LEFT JOIN `items` it ON (iv.`inv_itemid` = it.`itmid`) WHERE (`inv_userid` = ".$_SESSION['userid'].") AND (`inv_itemid` = ".abs(intval($_GET['ID'])).")") or die(mysql_error()); if(!mysql_num_rows($Data) || !ctype_digit($_GET['ID'])) { echo ('IamabitchAn error has occurred, please go back and try again.'); exit($h->endpage()); } $Data = mysql_fetch_array($Data); Add this before the mysql_query echo $_GET['ID']." "; If you don't get a number or it's blank, then that is your problem. If you get a number, match that number to the inv_itemid field in the inventory table in your database where your userid is the inv_userid field, so run this SQL command without the brackets. [mysql]SELECT inv_userid, inv_itemid FROM inventory WHERE inv_userid=(enter your userid) AND inv_itemid=(enter the ID you are checking)[/mysql] If you are not returned a result, then that means you are missing it from your inventory. Quote Link to comment Share on other sites More sharing options...
thebobby Posted January 27, 2011 Author Share Posted January 27, 2011 ("SELECT iv.`inv_itemid`,iv.`inv_userid`,iv.`inv_qty`,it.`itmid`,it.`itmname` FROM `inventory` iv LEFT JOIN `items` it ON (iv.`inv_itemid` = it.`itmid`) WHERE (`inv_userid` = ". thats the whole line 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.