Parse error: syntax error, unexpected

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Topbidder
    New Member
    • Jul 2010
    • 11

    #1

    Parse error: syntax error, unexpected

    I have this error on the code

    Parse error: syntax error, unexpected '"' in /home/topbidd/public_html/bid2/bid_classic.php on line 159

    now i thought the error was this

    It seems that the code has an extra " at the end before the ;

    VALUES('" .$auction_id. "','" .$user_id. "','"
    .converttonum(g et_next_bid($au ction_id)). "','" .$NOW. "')";

    But when i deleted the " it did remove the error message but took to white page instead of the error message does anyone have any idea's


    Code:
    <?include_once "./includes/config.inc.php";#// Run cron according to SETTINGSif($SETTINGS['cron'] == 2){	include_once "cron.php";}include_once $include_path . "auction_types.inc.php";include_once $include_path . "dates.inc.php";$TIME = mktime(date("H") + $SETTINGS['timecorrection'], date("i"), date("s"), date("m"), date("d"), date("Y"));$NOW = date("YmdHis", $TIME);
    #// #################################################// Is the seller logged in?if(!isset($_SESSION['BPPENNYAUTOBID_LOGGED_IN'])){	$REDIRECT_AFTER_LOGIN = "index.php";	$_SESSION['REDIRECT_AFTER_LOGIN'] = $REDIRECT_AFTER_LOGIN;	Header("Location: user_login.php");	exit();}
    if(!$id) $id = $_REQUEST[id];
    if(!$bid) $bid = $_REQUEST[bid];
    $auction_type = $_POST['auction_type'];
    $type = $_POST['form_type'];
    $TPL_id = $id;/** first check if valid auction ID passed */$result = mysql_query("SELECT * FROM BPPENNYAUTOBID_auctions WHERE id=" . intval($id));// SQL errorif(!$result){	MySQLError($query);	exit();}$Data = mysql_fetch_array($result);$n = mysql_num_rows($result);$TPL_title = htmlspecialchars($Data['title']);$TPL_id_value = $id;$TPL_auctions_list_value = "";$query = "select bid,id from BPPENNYAUTOBID_bids where auction=\"" . intval($id) . "\" ORDER BY id DESC";$result___ = mysql_query($query);if(mysql_num_rows($result___) > 0){	$ARETHEREBIDS = "<A HREF=\"" . $SETTINGS['siteurl'] . "item.php?id=$id&history=view#history\">$MSG_105</A>";	$CURRENTBID_ID = mysql_result($result___, 0, "id");}else{	unset($TPL_BIDS_value);}# // ###############################// $ITEM = mysql_fetch_array($result);// such auction does not exist, so exitif($n == 0){	include_once ("header.php");	$TPL_errmsg = $ERR_606;	include_once (phpa_include("template_bid_php.html"));	include_once ("footer.php");	exit();}
    # // ###############################    # check if the user has enough money on his account$bid_sum = 0;//echo "<pre>Data<br>";//print_r($Data);//echo "</pre>";// Retrieve bid value (one bid cost)if(ereg("^(\+?((([0-9]+(\.)?)|([0-9]*\.[0-9]+))([eE][+-]?[0-9]+)?))$", $Data['bid_value'])){	$bid_value = $Data['bid_value'];}else	$bid_value = 2;if($_POST['bid_type'] == 'simple'){	$bid_sum = $bid_value;}$query = "SELECT id, balance FROM BPPENNYAUTOBID_users WHERE nick='" . addslashes($_SESSION['BPPENNYAUTOBID_LOGGED_IN_USERNAME']) . "'";
    //echo "bid_sum = $bid_sum<br>sql: $query";$result_b = mysql_query($query);$bal_row = mysql_fetch_array($result_b);$balance_ = $bal_row['balance'];$user_id_ = $bal_row['id'];// the user has not enough money    if($balance_ < 1){	include_once ("header.php");	$TPL_errmsg = $ERR_32_0001;	$bidH = $bid_sum;	// Show list of bids	$auction_id = $id;	include_once ("bid_list.php");	include_once (phpa_include("template_bid_php.html"));	include_once ("footer.php");	exit();}$auctiondate = $Data['starts'];$auctionends = $Data['ends'];$item_title = $Data["title"];$item_description = $Data["description"];// check if auction isn't closed    $AuctionIsClosed = false;$closed = intval($Data["closed"]);$c = $Data["ends"];if(mktime(substr($c, 8, 2), substr($c, 10, 2), substr($c, 12, 2), substr($c, 4, 2), substr($c, 6, 2), substr($c, 0, 4)) <= $TIME) $AuctionIsClosed = true;if(($closed == 1) || ($AuctionIsClosed) || ($Data['suspended'] == 1)){	include_once ("header.php");	$TPL_errmsg = $ERR_614;	// Show list of bids	$auction_id = $id;	include_once ("bid_list.php");	include_once (phpa_include("template_bid_php.html"));	include_once ("footer.php");	exit();}$insert = "";// Check if the user pressed F5: if no - processing the bid, if yes - not processingif($_POST['f5_num'] != $_SESSION['f5_num1']){	// Insert records of each bid (one - if simple, multiple - if 'range')//	if($_POST['bid_type'] == 'simple')//	{//		$insert = "INSERT INTO BPPENNYAUTOBID_bids(auction, bidder, bid, bidwhen)//               VALUES($id, $user_id_, " . converttonum($_POST['bid']) . ", '$NOW')";//		
    //		mysql_query($insert);//	}//	//update user's balance    //	$balance_ -= 1;//	$update = "UPDATE BPPENNYAUTOBID_users SET balance=$balance_//                  WHERE nick LIKE '" . addslashes($_SESSION['BPPENNYAUTOBID_LOGGED_IN_USERNAME']) . "' AND id=$user_id_";//	mysql_query($update);
    do_bid($id,$user_id_,$_POST['bid']);
    autobidProcessing($id);	// Save current F5 control number for next check	$_SESSION['f5_num1'] = $_POST['f5_num'];}
    /** * NOTE: AUCTION AUTOEXTENSION */
    $EXTSETTINGS = @mysql_fetch_array(@mysql_query("SELECT * FROM BPPENNYAUTOBID_auctionextension"));
    if($EXTSETTINGS['status'] == 'enabled')
    {
    	$__END = mktime(substr($auctionends, 8, 2), substr($auctionends, 10, 2), substr($auctionends, 12, 2), substr($auctionends, 4, 2), substr($auctionends, 6, 2), substr($auctionends, 0, 4));
    	if(($__END - $TIME) <= $EXTSETTINGS['timebefore'])
    	{
    		$auctionends = date("YmdHis", mktime(substr($auctionends, 8, 2), substr($auctionends, 10, 2), substr($auctionends, 12, 2) + $EXTSETTINGS['extend'], substr($auctionends, 4, 2), substr($auctionends, 6, 2), substr($auctionends, 0, 4)));
    	}
    	$query = "UPDATE BPPENNYAUTOBID_auctions set ends='$auctionends' WHERE id=" . intval($id);
    	if(!mysql_query($query))
    	{
    		MySQLError($query);
    		exit();
    	}
    }        // Generate new F5 control number$f5_num = getRandomInt(20);// Check for winner - find maximum bid$check = "SELECT bid, bidder, COUNT(bid) AS bid_count              FROM BPPENNYAUTOBID_bids              WHERE auction=$id GROUP BY bid ORDER BY bid DESC ";$check_result = mysql_query($check);$winner_bid = 0;$winner_bid_count = 0;$winner_id = 0;if($check_row = mysql_fetch_array($check_result)){	$winner_bid = $check_row['bid'];	$winner_bid_count = $check_row['bid_count'];	if($winner_bid_count == 1) $winner_id = $check_row['bidder'];}// Find the current winner of the auction
    while($check_row = mysql_fetch_array($check_result)){	// Find out if the bid is unique        
    	if($check_row['bid_count'] == 1)	{		// If this unique bid is the highest - it is a winner
    		if($check_row['bid'] > $winner_bid)		{			$winner_id = $check_row['bidder'];			$winner_bid = $check_row['bid'];		}	}}$MSG_WINNER = "";$is_winner = false;if($winner_id == $_SESSION['BPPENNYAUTOBID_LOGGED_IN']){	$is_winner = true; // Current user is the winner}// Show message about current bid if it's winner bid, its state etc...switch($_POST['bid_type']){	case "simple":		$result3 = mysql_query($check);		$is_unique = false;		while($row3 = mysql_fetch_array($result3))		{			if($row3['bid_count'] == 1 && $row3['bid'] == $_POST['bid'])			{				$is_unique = true;				break;			}		}		if($_POST['bid'] == $winner_bid && $is_winner)		{ //This bid is winner		$MSG_WINNER = $MSG_31_0053;		}else		{			if($is_unique == true)			{				$MSG_WINNER = $MSG_31_0054;				if($is_winner == true)				{					$MSG_WINNER .= str_replace("<winner_bid>", $winner_bid, $MSG_31_0057);				}			}else			{				$MSG_WINNER = $MSG_31_0055;				if($is_winner == true)				{					$MSG_WINNER .= str_replace("<winner_bid>", $winner_bid, $MSG_31_0057);				}			}		}		break;	default:	break;}
    #########################  Next Bid    #########################################################//$query = "select max(bid) AS maxbid, bidder FROM BPPENNYAUTOBID_bids WHERE auction=" . intval($id) . " GROUP BY auction, bidder ORDER BY maxbid DESC";//
    //$result_bids = mysql_query($query);//$customincrement = mysql_result($result, 0, "increment");//$max_bid = mysql_result($result_bids, 0, "maxbid");//
    ////echo '$max_bid='.$max_bid;//$minimum_bid = mysql_result($result, 0, "minimum_bid");//if($max_bid == 0)//{//	$MAX_BID = $minimum_bid;//	//// Added by Yosi 22 Jul 2009 - consider if auction starts with some value//	$max_bid = $minimum_bid;//}else//{//	$MAX_BID = $max_bid;//}///* Get bid increment for current bid and calculate minimum bid *///
    //$query = "SELECT increment FROM BPPENNYAUTOBID_increments WHERE " . "((low <= $MAX_BID AND high >= $MAX_BID) OR " . "(low < $MAX_BID AND high < $MAX_BID)) ORDER BY increment DESC";//
    ////echo "<div style='display:none;'>sql:<br>";////echo "$query</div>";//
    //$result_incr = mysql_query($query);//if(mysql_num_rows($result_incr) != 0)//{//	$increment = mysql_result($result_incr, 0, "increment");//}//if($customincrement > 0)//{	//	$increment = $customincrement;//}//if($max_bid == 0 || $atype == 2)//{//	$next_bid = $minimum_bid;//}else//{	//	$next_bid = $max_bid + $increment;//}//$TPL_next_bid_value = $next_bid;
    $TPL_next_bid_value = get_next_bid($id);##################################################################//if($is_winner==false){//   $MSG_WINNER .= $MSG_31_0056;//}$auction_type = $_POST['auction_type'];$type = $_POST['form_type'];$TPL_id = $id;// Show list of bids$auction_id = $id;
    header("Location: item.php?id=".$id."&history=view#history");
    ////include_once ("bid_list.php");//include_once "header.php";//include_once phpa_include("template_bid_result_php.html");//include_once "footer.php";//exit();
    function get_HOW_MANY($auction_id)
    {
    	$how_many = "&nbsp;";
    	if(isset($_SESSION["BPPENNYAUTOBID_LOGGED_IN"]))
    	{
    		$sql = "SELECT asi.offers
                    FROM BPPENNYAUTOBID_auctions_signed asi
                    INNER JOIN BPPENNYAUTOBID_auctions a ON asi.auction_id=a.id
                    WHERE asi.user_id=" . $_SESSION["BPPENNYAUTOBID_LOGGED_IN"] . " AND
                       asi.auction_id=" . $auction_id . " AND a.auction_type>1";
    		$res = mysql_query($sql);
    		if($res)
    		{
    			if(mysql_num_rows($res) > 0)
    			{
    				$row1 = mysql_fetch_array($res);
    				$how_many = "Your number of offers available for this auction are: " . $row1['offers'];
    			}
    		}
    	}
    	return $how_many;
    }
    //--------------------------------------------------------------------------// gets random integer//--------------------------------------------------------------------------function getRandomInt($length = 20){	$template = "1234567890abcdefghijklmnopqrstuvwxyz";	//$template = "1234567890";	settype($template, "string");	settype($length, "integer");	settype($rndstring, "string");	settype($a, "integer");	settype($b, "integer");	for($a = 0; $a <= $length; $a++)	{		$b = rand(0, strlen($template) - 1);		$rndstring .= $template[$b];	}	return $rndstring;}function get_next_bid($auction_id) {
    	
    	if (intval($auction_id)>0) {
    		$result = mysql_query("SELECT * FROM BPPENNYAUTOBID_auctions WHERE id=" . intval($auction_id));
    		$result_bids = mysql_query("select max(bid) AS maxbid, bidder FROM BPPENNYAUTOBID_bids WHERE auction=" . intval($auction_id) . " GROUP BY auction, bidder ORDER BY maxbid DESC");
    
    		$customincrement = mysql_result($result, 0, "increment");
    		$max_bid = mysql_result($result_bids, 0, "maxbid");
    		$minimum_bid = mysql_result($result, 0, "minimum_bid");
    		if($max_bid == 0) {
    			$MAX_BID = $minimum_bid;
    			//// Added by Yosi 22 Jul 2009 - consider if auction starts with some value
    			$max_bid = $minimum_bid;
    		}else
    		{
    			$MAX_BID = $max_bid;
    		}
    		/* Get bid increment for current bid and calculate minimum bid */
    		
    		$query = "SELECT increment FROM BPPENNYAUTOBID_increments WHERE " . "((low <= $MAX_BID AND high >= $MAX_BID) OR " . "(low < $MAX_BID AND high < $MAX_BID)) ORDER BY increment DESC";
    		
    		//echo "<div style='display:none;'>sql:<br>";
    		//echo "$query</div>";
    		
    		$result_incr = mysql_query($query);
    		if(mysql_num_rows($result_incr) != 0)
    		{
    			$increment = mysql_result($result_incr, 0, "increment");
    		}
    		if($customincrement > 0)
    		{	
    			$increment = $customincrement;
    		}
    		
    		if($max_bid == 0 || $atype == 2)
    		{
    			$next_bid = $minimum_bid;
    		}else
    		{	
    			$next_bid = $max_bid + $increment;
    		}
    		return $next_bid;
    	} else {
    		return 0;
    	}
    }
    
    function autobidProcessing($auction_id=0) {
    	if (intval($auction_id)>0) {
    		//do {
    			$sql="SELECT
    					BPPENNYAUTOBID_autobids.id,
    					BPPENNYAUTOBID_autobids.bidder_id,
    					BPPENNYAUTOBID_autobids.remained_bids,
    					BPPENNYAUTOBID_autobids.max_amount,
    					BPPENNYAUTOBID_users.balance
    				FROM BPPENNYAUTOBID_autobids
    				INNER JOIN BPPENNYAUTOBID_users ON BPPENNYAUTOBID_autobids.bidder_id=BPPENNYAUTOBID_users.id
    				WHERE
    					BPPENNYAUTOBID_autobids.auction_id='".$auction_id."'";
    			$result=mysql_query($sql);
    			//$return_flag=false;
    			$bid_flag=false;
    			while($row=mysql_fetch_array($result)) {
    				if ($row['remained_bids']>0 && $row['max_amount']>get_next_bid($auction_id)) {
    					if ($row['bidder_id']!=get_current_bidder_id($auction_id)) {
    						if (do_bid($auction_id,$row['bidder_id'],get_next_bid($auction_id))) {
    							mysql_query("UPDATE BPPENNYAUTOBID_autobids SET remained_bids=remained_bids-1 WHERE id='".$row['id']."'");
    							$bid_flag=true;
    						}
    					}
    				}
    			}
    		//} while ($bid_flag);
    	}
    }
    
    
    function do_bid($auction_id,$user_id,$bid_value) {
    	global $NOW;
    	
    	
    	if (intval($auction_id)>0 && intval($user_id)>0 && $bid_value>0) {
    		
    		$result_b = mysql_query("SELECT id, balance FROM BPPENNYAUTOBID_users WHERE id='" .$user_id. "'");
    		$bal_row = mysql_fetch_array($result_b);
    		$balance = $bal_row['balance'];
    		
    		$sql="SELECT ends,bid_value,closed,w_seat FROM BPPENNYAUTOBID_auctions WHERE id='".$auction_id."'";
            $result1=mysql_query($sql);
            $ends = mysql_result($result1, 0, "ends");
    		$closed = mysql_result($result1, 0, "closed");
    		$w_seat=mysql_result($result1, 0, "w_seat");		
    		if ($closed==0) {	
    			if (($balance>0 && $w_seat==1)||($w_seat==2)) {
    				if ((strtotime($ends)-strtotime($NOW)>=0) && (strtotime($ends)-strtotime($NOW)<=15)) {					//$new_ends=date("YmdHis",strtotime($NOW)+32);					//mysql_query("UPDATE BPPENNYAUTOBID_auctions SET jump30=1 WHERE id='".$auction_id."'");					//echo "UPDATE auctions SET ends='".$new_ends."' WHERE auction_id='".$auction_id."'";					$new_ends=date("YmdHis",strtotime($ends)+15-(strtotime($ends)-strtotime($NOW))+1);					mysql_query("UPDATE BPPENNYAUTOBID_auctions SET ends='".$new_ends."', jump30=0 WHERE id='".$auction_id."'");									}				if (strtotime($ends)-strtotime($NOW)>=0) {					$insert = "INSERT INTO BPPENNYAUTOBID_bids(auction, bidder, bid, bidwhen)
    							   VALUES('" .$auction_id. "','" .$user_id.  "','" .converttonum(get_next_bid($auction_id)). "','" .$NOW. "')";
    						
    					
    					mysql_query($insert);
    					
    	
    					if ($w_seat==1) {
    						$balance -= 1;
    						$update = "UPDATE BPPENNYAUTOBID_users SET balance=".$balance."
    									  WHERE id=".$user_id;
    						
    						mysql_query($update);					}					return true;				} else {					return false;				}
    			} else {
    				return false;	
    			}
    		} else {
    			return false;
    		}
    	} else {
    		return false;
    	}
    }
    
    function converttonum($convertnum){
    	$bits = explode(",",$convertnum); // split input value up to allow checking
       
    	$first = strlen($bits[0]); // gets part before first comma (thousands/millions)
    	$last = strlen($bits[1]); // gets part after first comma (thousands (or decimals if incorrectly used by user)
       
    	if ($last <3){ // checks for comma being used as decimal place
    		$convertnum = str_replace(",",".",$convertnum);
    	}
    	else{ // assume comma is a thousands seperator, so remove it
    		$convertnum = str_replace(",","",$convertnum);
    	}
       
    	return $convertnum; 
    } 
    
    function get_current_bidder_id($auction_id) {
    	$sql = "SELECT bid, bidder, COUNT(bid) AS bid_count
                  FROM BPPENNYAUTOBID_bids
                  WHERE auction=".$auction_id." GROUP BY bid ORDER BY bid DESC ";
    	$result = mysql_query($sql);
    	if ($row1=mysql_fetch_array($result)) {
    		return $row1['bidder'];
    	} else {
    		return 0;
    	}
    }
    ?>
  • JKing
    Recognized Expert Top Contributor
    • Jun 2007
    • 1206

    #2
    May I inquire as to why the majority of your program is commented out?

    I don't see any output that hasn't been commented out. So your program executes without error but has no output resulting in a blank white page.

    Comment

    • Topbidder
      New Member
      • Jul 2010
      • 11

      #3
      RE: Parse error: syntax error, unexpected

      so i am not sure how to fix it and not get the error or white page if you have information on how i can fix i am still in the learning process so if you know a tutorial that would explain better how to fix the /bid_classic.php or just get new one that works without issue

      many thanks

      Comment

      • TheServant
        Recognized Expert Top Contributor
        • Feb 2008
        • 1168

        #4
        The problem is in:
        Code:
        $insert = "INSERT INTO BPPENNYAUTOBID_bids(auction, bidder, bid, bidwhen) VALUES('" .$auction_id. "','" .$user_id.  "','" .converttonum(get_next_bid($auction_id)). "','" .$NOW. "')";
        Should be:
        Code:
        $temp_num = converttonum(get_next_bid($auction_id));
        $insert = "INSERT INTO BPPENNYAUTOBID_bids(auction, bidder, bid, bidwhen) VALUES('$auction_id','$user_id','$temp_num','$NOW')";
        In your code you were not joining the strings:
        Code:
        VALUES('" .$auction_id. "','" .$user_id. "','"
        .converttonum(get_next_bid($auction_id)). "','" .$NOW. "')";
        // SHOULD BE
        VALUES('" .$auction_id. ".','." .$user_id. ".','."
        .converttonum(get_next_bid($auction_id)). ".','." .$NOW. ".').";
        See all the extra .'s? But as I say, you don't need all that concatenation.
        Last edited by TheServant; Jul 10 '10, 05:29 AM. Reason: Edited to add semi-colon, and single quotes as JKing stated.

        Comment

        • JKing
          Recognized Expert Top Contributor
          • Jun 2007
          • 1206

          #5
          Originally posted by TheServant
          The problem is in:
          Code:
          $insert = "INSERT INTO BPPENNYAUTOBID_bids(auction, bidder, bid, bidwhen) VALUES('" .$auction_id. "','" .$user_id.  "','" .converttonum(get_next_bid($auction_id)). "','" .$NOW. "')";
          Should be:
          Code:
          $temp_num = converttonum(get_next_bid($auction_id))
          $insert = "INSERT INTO BPPENNYAUTOBID_bids(auction, bidder, bid, bidwhen) VALUES($auction_id,$user_id,$temp_num,$NOW)";
          In your code you were not joining the strings:
          Code:
          VALUES('" .$auction_id. "','" .$user_id. "','"
          .converttonum(get_next_bid($auction_id)). "','" .$NOW. "')";
          // SHOULD BE
          VALUES('" .$auction_id. ".','." .$user_id. ".','."
          .converttonum(get_next_bid($auction_id)). ".','." .$NOW. ".').";
          See all the extra .'s? But as I say, you don't need all that concatenation.
          I disagree TheServant.

          The first code block you posted is correct.

          The second code block you posted is wrong. Line 1 is unnecessary and missing a semi-colon too.
          Line 2 will produce errors if any of those variables contain strings. If you are going to place the variables directly into the string without breaking them out and concatenating you will still need to surround them with single quotes.

          And your third code block would be inserting a whole lot of periods(fullsto ps) into the database.

          As I said before there is no output in the OP's script. There is a whole ton of code that has been commented out. Likely there for debugging purposes.

          Comment

          • TheServant
            Recognized Expert Top Contributor
            • Feb 2008
            • 1168

            #6
            Thanks JKing. Been spending a bit too much time in VB recently. The third code block is an example to show what was wrong with his original code with breaking a string started with double quotes and then not joining the breaks. Anyway, thanks again the the pickup.

            Also check line 168, you have not closed your string and it needs a rewrite. Getting a PHP editor like phpDesigner highlights these sort of errors.

            Comment

            • Topbidder
              New Member
              • Jul 2010
              • 11

              #7
              Awesome thanks i will do that and go over the who code

              Comment

              • JKing
                Recognized Expert Top Contributor
                • Jun 2007
                • 1206

                #8
                Originally posted by TheServant
                Thanks JKing. Been spending a bit too much time in VB recently. The third code block is an example to show what was wrong with his original code with breaking a string started with double quotes and then not joining the breaks. Anyway, thanks again the the pickup.

                Also check line 168, you have not closed your string and it needs a rewrite. Getting a PHP editor like phpDesigner highlights these sort of errors.
                I understand the third code block was meant to be an example but the "Should Be" portion of that block is incorrect and would be inserting . around each variable in the database was my point.

                Also nothing wrong with line 168. It is part of an update statement.
                Code:
                $update = "UPDATE BPPENNYAUTOBID_users SET balance=".$balance."                                       
                WHERE id=".$user_id;
                Whitespace and line breaks are ignored by PHP

                Comment

                • Topbidder
                  New Member
                  • Jul 2010
                  • 11

                  #9
                  wow i changed that now i got this lol
                  this is the site i have the error on



                  Parse error: syntax error, unexpected T_STRING in /home/topbidd/public_html/bid2/bid_classic.php on line 167


                  Could someone please fix the code an then i can go study it and learn the correct way and physically see the whole code correctly and in correctly done

                  thank you so much

                  here is the whole code if someone would like to rewrite it correctly so i can see it correct and in correct to compare them
                  Code:
                  <?
                  include_once "./includes/config.inc.php";
                  #// Run cron according to SETTINGS
                  if($SETTINGS['cron'] == 2)
                  {
                  	include_once "cron.php";
                  }
                  include_once $include_path . "auction_types.inc.php";
                  include_once $include_path . "dates.inc.php";
                  $TIME = mktime(date("H") + $SETTINGS['timecorrection'], date("i"), date("s"), date("m"), date("d"), date("Y"));
                  $NOW = date("YmdHis", $TIME);
                  
                  #// ################################################
                  #// Is the seller logged in?
                  if(!isset($_SESSION['BPPENNYAUTOBID_LOGGED_IN']))
                  {
                  	$REDIRECT_AFTER_LOGIN = "index.php";
                  	$_SESSION['REDIRECT_AFTER_LOGIN'] = $REDIRECT_AFTER_LOGIN;
                  	Header("Location: user_login.php");
                  	exit();
                  }
                  
                  
                  if(!$id) $id = $_REQUEST[id];
                  
                  if(!$bid) $bid = $_REQUEST[bid];
                  
                  $auction_type = $_POST['auction_type'];
                  
                  $type = $_POST['form_type'];
                  
                  $TPL_id = $id;
                  /** first check if valid auction ID passed */
                  $result = mysql_query("SELECT * FROM BPPENNYAUTOBID_auctions WHERE id=" . intval($id));
                  // SQL error
                  if(!$result)
                  {
                  	MySQLError($query);
                  	exit();
                  }
                  $Data = mysql_fetch_array($result);
                  $n = mysql_num_rows($result);
                  $TPL_title = htmlspecialchars($Data['title']);
                  $TPL_id_value = $id;
                  $TPL_auctions_list_value = "";
                  $query = "select bid,id from BPPENNYAUTOBID_bids where auction=\"" . intval($id) . "\" ORDER BY id DESC";
                  $result___ = mysql_query($query);
                  if(mysql_num_rows($result___) > 0)
                  {
                  	$ARETHEREBIDS = "<A HREF=\"" . $SETTINGS['siteurl'] . "item.php?id=$id&history=view#history\">$MSG_105</A>";
                  	$CURRENTBID_ID = mysql_result($result___, 0, "id");
                  }else
                  {
                  	unset($TPL_BIDS_value);
                  }
                  # // ###############################
                  // $ITEM = mysql_fetch_array($result);
                  // such auction does not exist, so exit
                  if($n == 0)
                  {
                  	include_once ("header.php");
                  	$TPL_errmsg = $ERR_606;
                  	include_once (phpa_include("template_bid_php.html"));
                  	include_once ("footer.php");
                  	exit();
                  }
                  
                  # // ###############################    
                  # check if the user has enough money on his account
                  $bid_sum = 0;
                  //echo "<pre>Data<br>";
                  //print_r($Data);
                  //echo "</pre>";
                  // Retrieve bid value (one bid cost)
                  if(ereg("^(\+?((([0-9]+(\.)?)|([0-9]*\.[0-9]+))([eE][+-]?[0-9]+)?))$", $Data['bid_value']))
                  {
                  	$bid_value = $Data['bid_value'];
                  }else
                  	$bid_value = 2;
                  if($_POST['bid_type'] == 'simple')
                  {
                  	$bid_sum = $bid_value;
                  }
                  $query = "SELECT id, balance FROM BPPENNYAUTOBID_users WHERE nick='" . addslashes($_SESSION['BPPENNYAUTOBID_LOGGED_IN_USERNAME']) . "'";
                  
                  //echo "bid_sum = $bid_sum<br>sql: $query";
                  $result_b = mysql_query($query);
                  $bal_row = mysql_fetch_array($result_b);
                  $balance_ = $bal_row['balance'];
                  $user_id_ = $bal_row['id'];
                  // the user has not enough money    
                  if($balance_ < 1)
                  {
                  	include_once ("header.php");
                  	$TPL_errmsg = $ERR_32_0001;
                  	$bidH = $bid_sum;
                  	// Show list of bids
                  	$auction_id = $id;
                  	include_once ("bid_list.php");
                  	include_once (phpa_include("template_bid_php.html"));
                  	include_once ("footer.php");
                  	exit();
                  }
                  $auctiondate = $Data['starts'];
                  $auctionends = $Data['ends'];
                  $item_title = $Data["title"];
                  $item_description = $Data["description"];
                  // check if auction isn't closed    
                  $AuctionIsClosed = false;
                  $closed = intval($Data["closed"]);
                  $c = $Data["ends"];
                  if(mktime(substr($c, 8, 2), substr($c, 10, 2), substr($c, 12, 2), substr($c, 4, 2), substr($c, 6, 2), substr($c, 0, 4)) <= $TIME) $AuctionIsClosed = true;
                  if(($closed == 1) || ($AuctionIsClosed) || ($Data['suspended'] == 1))
                  {
                  	include_once ("header.php");
                  	$TPL_errmsg = $ERR_614;
                  	// Show list of bids
                  	$auction_id = $id;
                  	include_once ("bid_list.php");
                  	include_once (phpa_include("template_bid_php.html"));
                  	include_once ("footer.php");
                  	exit();
                  }
                  $insert = "";
                  // Check if the user pressed F5: if no - processing the bid, if yes - not processing
                  if($_POST['f5_num'] != $_SESSION['f5_num1'])
                  {
                  	// Insert records of each bid (one - if simple, multiple - if 'range')
                  //	if($_POST['bid_type'] == 'simple')
                  //	{
                  //		$insert = "INSERT INTO BPPENNYAUTOBID_bids(auction, bidder, bid, bidwhen)
                  //               VALUES($id, $user_id_, " . converttonum($_POST['bid']) . ", '$NOW')";
                  //		
                  //		mysql_query($insert);
                  //	}
                  //	//update user's balance    
                  //	$balance_ -= 1;
                  //	$update = "UPDATE BPPENNYAUTOBID_users SET balance=$balance_
                  //                  WHERE nick LIKE '" . addslashes($_SESSION['BPPENNYAUTOBID_LOGGED_IN_USERNAME']) . "' AND id=$user_id_";
                  //	mysql_query($update);
                  do_bid($id,$user_id_,$_POST['bid']);
                  autobidProcessing($id);
                  	// Save current F5 control number for next check
                  	$_SESSION['f5_num1'] = $_POST['f5_num'];
                  }
                  
                  
                  /**
                   * NOTE: AUCTION AUTOEXTENSION
                   */
                  $EXTSETTINGS = @mysql_fetch_array(@mysql_query("SELECT * FROM BPPENNYAUTOBID_auctionextension"));
                  if($EXTSETTINGS['status'] == 'enabled')
                  {
                  	$__END = mktime(substr($auctionends, 8, 2), substr($auctionends, 10, 2), substr($auctionends, 12, 2), substr($auctionends, 4, 2), substr($auctionends, 6, 2), substr($auctionends, 0, 4));
                  	if(($__END - $TIME) <= $EXTSETTINGS['timebefore'])
                  	{
                  		$auctionends = date("YmdHis", mktime(substr($auctionends, 8, 2), substr($auctionends, 10, 2), substr($auctionends, 12, 2) + $EXTSETTINGS['extend'], substr($auctionends, 4, 2), substr($auctionends, 6, 2), substr($auctionends, 0, 4)));
                  	}
                  	$query = "UPDATE BPPENNYAUTOBID_auctions set ends='$auctionends' WHERE id=" . intval($id);
                  	if(!mysql_query($query))
                  	{
                  		MySQLError($query);
                  		exit();
                  	}
                  }
                  
                          
                  // Generate new F5 control number
                  $f5_num = getRandomInt(20);
                  // Check for winner - find maximum bid
                  $check = "SELECT bid, bidder, COUNT(bid) AS bid_count
                                FROM BPPENNYAUTOBID_bids
                                WHERE auction=$id GROUP BY bid ORDER BY bid DESC ";
                  $check_result = mysql_query($check);
                  $winner_bid = 0;
                  $winner_bid_count = 0;
                  $winner_id = 0;
                  if($check_row = mysql_fetch_array($check_result))
                  {
                  	$winner_bid = $check_row['bid'];
                  	$winner_bid_count = $check_row['bid_count'];
                  	if($winner_bid_count == 1) $winner_id = $check_row['bidder'];
                  }
                  // Find the current winner of the auction
                  
                  while($check_row = mysql_fetch_array($check_result))
                  {
                  	// Find out if the bid is unique        
                  
                  	if($check_row['bid_count'] == 1)
                  	{
                  		// If this unique bid is the highest - it is a winner
                  
                  		if($check_row['bid'] > $winner_bid)
                  		{
                  			$winner_id = $check_row['bidder'];
                  			$winner_bid = $check_row['bid'];
                  		}
                  	}
                  }
                  $MSG_WINNER = "";
                  $is_winner = false;
                  if($winner_id == $_SESSION['BPPENNYAUTOBID_LOGGED_IN'])
                  {
                  	$is_winner = true; // Current user is the winner
                  }
                  // Show message about current bid if it's winner bid, its state etc...
                  switch($_POST['bid_type'])
                  {
                  	case "simple":
                  		$result3 = mysql_query($check);
                  		$is_unique = false;
                  		while($row3 = mysql_fetch_array($result3))
                  		{
                  			if($row3['bid_count'] == 1 && $row3['bid'] == $_POST['bid'])
                  			{
                  				$is_unique = true;
                  				break;
                  			}
                  		}
                  		if($_POST['bid'] == $winner_bid && $is_winner)
                  		{ //This bid is winner
                  		$MSG_WINNER = $MSG_31_0053;
                  		}else
                  		{
                  			if($is_unique == true)
                  			{
                  				$MSG_WINNER = $MSG_31_0054;
                  				if($is_winner == true)
                  				{
                  					$MSG_WINNER .= str_replace("<winner_bid>", $winner_bid, $MSG_31_0057);
                  				}
                  			}else
                  			{
                  				$MSG_WINNER = $MSG_31_0055;
                  				if($is_winner == true)
                  				{
                  					$MSG_WINNER .= str_replace("<winner_bid>", $winner_bid, $MSG_31_0057);
                  				}
                  			}
                  		}
                  		break;
                  	default:
                  	break;
                  }
                  
                  #########################  Next Bid    #########################################################
                  //$query = "select max(bid) AS maxbid, bidder FROM BPPENNYAUTOBID_bids WHERE auction=" . intval($id) . " GROUP BY auction, bidder ORDER BY maxbid DESC";
                  //
                  //$result_bids = mysql_query($query);
                  //$customincrement = mysql_result($result, 0, "increment");
                  //$max_bid = mysql_result($result_bids, 0, "maxbid");
                  //
                  ////echo '$max_bid='.$max_bid;
                  //$minimum_bid = mysql_result($result, 0, "minimum_bid");
                  //if($max_bid == 0)
                  //{
                  //	$MAX_BID = $minimum_bid;
                  //	//// Added by Yosi 22 Jul 2009 - consider if auction starts with some value
                  //	$max_bid = $minimum_bid;
                  //}else
                  //{
                  //	$MAX_BID = $max_bid;
                  //}
                  ///* Get bid increment for current bid and calculate minimum bid */
                  //
                  //$query = "SELECT increment FROM BPPENNYAUTOBID_increments WHERE " . "((low <= $MAX_BID AND high >= $MAX_BID) OR " . "(low < $MAX_BID AND high < $MAX_BID)) ORDER BY increment DESC";
                  //
                  ////echo "<div style='display:none;'>sql:<br>";
                  ////echo "$query</div>";
                  //
                  //$result_incr = mysql_query($query);
                  //if(mysql_num_rows($result_incr) != 0)
                  //{
                  //	$increment = mysql_result($result_incr, 0, "increment");
                  //}
                  //if($customincrement > 0)
                  //{	
                  //	$increment = $customincrement;
                  //}
                  //if($max_bid == 0 || $atype == 2)
                  //{
                  //	$next_bid = $minimum_bid;
                  //}else
                  //{	
                  //	$next_bid = $max_bid + $increment;
                  //}
                  //$TPL_next_bid_value = $next_bid;
                  $TPL_next_bid_value = get_next_bid($id);
                  ##################################################################
                  //if($is_winner==false){
                  //   $MSG_WINNER .= $MSG_31_0056;
                  //}
                  $auction_type = $_POST['auction_type'];
                  $type = $_POST['form_type'];
                  $TPL_id = $id;
                  // Show list of bids
                  $auction_id = $id;
                  header("Location: item.php?id=".$id."&history=view#history");
                  //
                  //include_once ("bid_list.php");
                  //include_once "header.php";
                  //include_once phpa_include("template_bid_result_php.html");
                  //include_once "footer.php";
                  //exit();
                  
                  function get_HOW_MANY($auction_id)
                  {
                  	$how_many = "&nbsp;";
                  	if(isset($_SESSION["BPPENNYAUTOBID_LOGGED_IN"]))
                  	{
                  		$sql = "SELECT asi.offers
                                  FROM BPPENNYAUTOBID_auctions_signed asi
                                  INNER JOIN BPPENNYAUTOBID_auctions a ON asi.auction_id=a.id
                                  WHERE asi.user_id=" . $_SESSION["BPPENNYAUTOBID_LOGGED_IN"] . " AND
                                     asi.auction_id=" . $auction_id . " AND a.auction_type>1";
                  		$res = mysql_query($sql);
                  		if($res)
                  		{
                  			if(mysql_num_rows($res) > 0)
                  			{
                  				$row1 = mysql_fetch_array($res);
                  				$how_many = "Your number of offers available for this auction are: " . $row1['offers'];
                  			}
                  		}
                  	}
                  	return $how_many;
                  }
                  
                  //--------------------------------------------------------------------------
                  // gets random integer
                  //--------------------------------------------------------------------------
                  function getRandomInt($length = 20)
                  {
                  	$template = "1234567890abcdefghijklmnopqrstuvwxyz";
                  	//$template = "1234567890";
                  	settype($template, "string");
                  	settype($length, "integer");
                  	settype($rndstring, "string");
                  	settype($a, "integer");
                  	settype($b, "integer");
                  	for($a = 0; $a <= $length; $a++)
                  	{
                  		$b = rand(0, strlen($template) - 1);
                  		$rndstring .= $template[$b];
                  	}
                  	return $rndstring;
                  }
                  function get_next_bid($auction_id) {
                  	
                  	if (intval($auction_id)>0) {
                  		$result = mysql_query("SELECT * FROM BPPENNYAUTOBID_auctions WHERE id=" . intval($auction_id));
                  		$result_bids = mysql_query("select max(bid) AS maxbid, bidder FROM BPPENNYAUTOBID_bids WHERE auction=" . intval($auction_id) . " GROUP BY auction, bidder ORDER BY maxbid DESC");
                  
                  		$customincrement = mysql_result($result, 0, "increment");
                  		$max_bid = mysql_result($result_bids, 0, "maxbid");
                  		$minimum_bid = mysql_result($result, 0, "minimum_bid");
                  		if($max_bid == 0) {
                  			$MAX_BID = $minimum_bid;
                  			//// Added by Yosi 22 Jul 2009 - consider if auction starts with some value
                  			$max_bid = $minimum_bid;
                  		}else
                  		{
                  			$MAX_BID = $max_bid;
                  		}
                  		/* Get bid increment for current bid and calculate minimum bid */
                  		
                  		$query = "SELECT increment FROM BPPENNYAUTOBID_increments WHERE " . "((low <= $MAX_BID AND high >= $MAX_BID) OR " . "(low < $MAX_BID AND high < $MAX_BID)) ORDER BY increment DESC";
                  		
                  		//echo "<div style='display:none;'>sql:<br>";
                  		//echo "$query</div>";
                  		
                  		$result_incr = mysql_query($query);
                  		if(mysql_num_rows($result_incr) != 0)
                  		{
                  			$increment = mysql_result($result_incr, 0, "increment");
                  		}
                  		if($customincrement > 0)
                  		{	
                  			$increment = $customincrement;
                  		}
                  		
                  		if($max_bid == 0 || $atype == 2)
                  		{
                  			$next_bid = $minimum_bid;
                  		}else
                  		{	
                  			$next_bid = $max_bid + $increment;
                  		}
                  		return $next_bid;
                  	} else {
                  		return 0;
                  	}
                  }
                  
                  function autobidProcessing($auction_id=0) {
                  	if (intval($auction_id)>0) {
                  		//do {
                  			$sql="SELECT
                  					BPPENNYAUTOBID_autobids.id,
                  					BPPENNYAUTOBID_autobids.bidder_id,
                  					BPPENNYAUTOBID_autobids.remained_bids,
                  					BPPENNYAUTOBID_autobids.max_amount,
                  					BPPENNYAUTOBID_users.balance
                  				FROM BPPENNYAUTOBID_autobids
                  				INNER JOIN BPPENNYAUTOBID_users ON BPPENNYAUTOBID_autobids.bidder_id=BPPENNYAUTOBID_users.id
                  				WHERE
                  					BPPENNYAUTOBID_autobids.auction_id='".$auction_id."'";
                  			$result=mysql_query($sql);
                  			//$return_flag=false;
                  			$bid_flag=false;
                  			while($row=mysql_fetch_array($result)) {
                  				if ($row['remained_bids']>0 && $row['max_amount']>get_next_bid($auction_id)) {
                  					if ($row['bidder_id']!=get_current_bidder_id($auction_id)) {
                  						if (do_bid($auction_id,$row['bidder_id'],get_next_bid($auction_id))) {
                  							mysql_query("UPDATE BPPENNYAUTOBID_autobids SET remained_bids=remained_bids-1 WHERE id='".$row['id']."'");
                  							$bid_flag=true;
                  						}
                  					}
                  				}
                  			}
                  		//} while ($bid_flag);
                  	}
                  }
                  
                  
                  function do_bid($auction_id,$user_id,$bid_value) {
                  	global $NOW;
                  	
                  	
                  	if (intval($auction_id)>0 && intval($user_id)>0 && $bid_value>0) {
                  		
                  		$result_b = mysql_query("SELECT id, balance FROM BPPENNYAUTOBID_users WHERE id='" .$user_id. "'");
                  		$bal_row = mysql_fetch_array($result_b);
                  		$balance = $bal_row['balance'];
                  		
                  		$sql="SELECT ends,bid_value,closed,w_seat FROM BPPENNYAUTOBID_auctions WHERE id='".$auction_id."'";
                          $result1=mysql_query($sql);
                          $ends = mysql_result($result1, 0, "ends");
                  		$closed = mysql_result($result1, 0, "closed");
                  		$w_seat=mysql_result($result1, 0, "w_seat");
                  		
                  		if ($closed==0) {	
                  			if (($balance>0 && $w_seat==1)||($w_seat==2)) {
                  				if ((strtotime($ends)-strtotime($NOW)>=0) && (strtotime($ends)-strtotime($NOW)<=15)) {
                  					//$new_ends=date("YmdHis",strtotime($NOW)+32);
                  					//mysql_query("UPDATE BPPENNYAUTOBID_auctions SET jump30=1 WHERE id='".$auction_id."'");
                  					//echo "UPDATE auctions SET ends='".$new_ends."' WHERE auction_id='".$auction_id."'";
                  					$new_ends=date("YmdHis",strtotime($ends)+15-(strtotime($ends)-strtotime($NOW))+1);
                  					mysql_query("UPDATE BPPENNYAUTOBID_auctions SET ends='".$new_ends."', jump30=0 WHERE id='".$auction_id."'");
                  					
                  				}
                  				if (strtotime($ends)-strtotime($NOW)>=0) {
                  					$insert = "INSERT INTO BPPENNYAUTOBID_bids(auction, bidder, bid, bidwhen)
                  							   VALUES('" .$auction_id. "','" .$user_id. "','" .converttonum(get_next_bid($auction_id)). "','" .$NOW. "')";
                  						
                  					
                  					mysql_query($insert);
                  					
                  	
                  					if ($w_seat==1) {
                  						$balance -= 1;
                  						$update = "UPDATE BPPENNYAUTOBID_users SET balance=".$balance."
                  									  WHERE id=".$user_id;
                  						
                  						mysql_query($update);
                  					}
                  					return true;
                  				} else {
                  					return false;
                  				}
                  			} else {
                  				return false;	
                  			}
                  		} else {
                  			return false;
                  		}
                  	} else {
                  		return false;
                  	}
                  }
                  
                  function converttonum($convertnum){
                  	$bits = explode(",",$convertnum); // split input value up to allow checking
                     
                  	$first = strlen($bits[0]); // gets part before first comma (thousands/millions)
                  	$last = strlen($bits[1]); // gets part after first comma (thousands (or decimals if incorrectly used by user)
                     
                  	if ($last <3){ // checks for comma being used as decimal place
                  		$convertnum = str_replace(",",".",$convertnum);
                  	}
                  	else{ // assume comma is a thousands seperator, so remove it
                  		$convertnum = str_replace(",","",$convertnum);
                  	}
                     
                  	return $convertnum; 
                  } 
                  
                  function get_current_bidder_id($auction_id) {
                  	$sql = "SELECT bid, bidder, COUNT(bid) AS bid_count
                                FROM BPPENNYAUTOBID_bids
                                WHERE auction=".$auction_id." GROUP BY bid ORDER BY bid DESC ";
                  	$result = mysql_query($sql);
                  	if ($row1=mysql_fetch_array($result)) {
                  		return $row1['bidder'];
                  	} else {
                  		return 0;
                  	}
                  }
                  
                  ?>

                  Comment

                  • Dormilich
                    Recognized Expert Expert
                    • Aug 2008
                    • 8694

                    #10
                    which is line 167? (in your listing line 167 is empty)

                    Comment

                    • Topbidder
                      New Member
                      • Jul 2010
                      • 11

                      #11
                      hmmm i will have to check im not too sure


                      here is line 167 showing on my php
                      Code:
                      					if ($w_seat==1) {
                      						$balance -= 1;
                      						# $update = "UPDATE BPPENNYAUTOBID_users SET balance=".$balance."                                       
                                                                                                            WHERE id=".$user_id;
                      						
                      						mysql_query($update);					}


                      but here is the whole code
                      Code:
                      <?include_once "./includes/config.inc.php";#// Run cron according to SETTINGSif($SETTINGS['cron'] == 2){	include_once "cron.php";}include_once $include_path . "auction_types.inc.php";include_once $include_path . "dates.inc.php";$TIME = mktime(date("H") + $SETTINGS['timecorrection'], date("i"), date("s"), date("m"), date("d"), date("Y"));$NOW = date("YmdHis", $TIME);
                      #// #################################################// Is the seller logged in?if(!isset($_SESSION['BPPENNYAUTOBID_LOGGED_IN'])){	$REDIRECT_AFTER_LOGIN = "index.php";	$_SESSION['REDIRECT_AFTER_LOGIN'] = $REDIRECT_AFTER_LOGIN;	Header("Location: user_login.php");	exit();}
                      if(!$id) $id = $_REQUEST[id];
                      if(!$bid) $bid = $_REQUEST[bid];
                      $auction_type = $_POST['auction_type'];
                      $type = $_POST['form_type'];
                      $TPL_id = $id;/** first check if valid auction ID passed */$result = mysql_query("SELECT * FROM BPPENNYAUTOBID_auctions WHERE id=" . intval($id));// SQL errorif(!$result){	MySQLError($query);	exit();}$Data = mysql_fetch_array($result);$n = mysql_num_rows($result);$TPL_title = htmlspecialchars($Data['title']);$TPL_id_value = $id;$TPL_auctions_list_value = "";$query = "select bid,id from BPPENNYAUTOBID_bids where auction=\"" . intval($id) . "\" ORDER BY id DESC";$result___ = mysql_query($query);if(mysql_num_rows($result___) > 0){	$ARETHEREBIDS = "<A HREF=\"" . $SETTINGS['siteurl'] . "item.php?id=$id&history=view#history\">$MSG_105</A>";	$CURRENTBID_ID = mysql_result($result___, 0, "id");}else{	unset($TPL_BIDS_value);}# // ###############################// $ITEM = mysql_fetch_array($result);// such auction does not exist, so exitif($n == 0){	include_once ("header.php");	$TPL_errmsg = $ERR_606;	include_once (phpa_include("template_bid_php.html"));	include_once ("footer.php");	exit();}
                      # // ###############################    # check if the user has enough money on his account$bid_sum = 0;//echo "<pre>Data<br>";//print_r($Data);//echo "</pre>";// Retrieve bid value (one bid cost)if(ereg("^(\+?((([0-9]+(\.)?)|([0-9]*\.[0-9]+))([eE][+-]?[0-9]+)?))$", $Data['bid_value'])){	$bid_value = $Data['bid_value'];}else	$bid_value = 2;if($_POST['bid_type'] == 'simple'){	$bid_sum = $bid_value;}$query = "SELECT id, balance FROM BPPENNYAUTOBID_users WHERE nick='" . addslashes($_SESSION['BPPENNYAUTOBID_LOGGED_IN_USERNAME']) . "'";
                      //echo "bid_sum = $bid_sum<br>sql: $query";$result_b = mysql_query($query);$bal_row = mysql_fetch_array($result_b);$balance_ = $bal_row['balance'];$user_id_ = $bal_row['id'];// the user has not enough money    if($balance_ < 1){	include_once ("header.php");	$TPL_errmsg = $ERR_32_0001;	$bidH = $bid_sum;	// Show list of bids	$auction_id = $id;	include_once ("bid_list.php");	include_once (phpa_include("template_bid_php.html"));	include_once ("footer.php");	exit();}$auctiondate = $Data['starts'];$auctionends = $Data['ends'];$item_title = $Data["title"];$item_description = $Data["description"];// check if auction isn't closed    $AuctionIsClosed = false;$closed = intval($Data["closed"]);$c = $Data["ends"];if(mktime(substr($c, 8, 2), substr($c, 10, 2), substr($c, 12, 2), substr($c, 4, 2), substr($c, 6, 2), substr($c, 0, 4)) <= $TIME) $AuctionIsClosed = true;if(($closed == 1) || ($AuctionIsClosed) || ($Data['suspended'] == 1)){	include_once ("header.php");	$TPL_errmsg = $ERR_614;	// Show list of bids	$auction_id = $id;	include_once ("bid_list.php");	include_once (phpa_include("template_bid_php.html"));	include_once ("footer.php");	exit();}$insert = "";// Check if the user pressed F5: if no - processing the bid, if yes - not processingif($_POST['f5_num'] != $_SESSION['f5_num1']){	// Insert records of each bid (one - if simple, multiple - if 'range')//	if($_POST['bid_type'] == 'simple')//	{//		$insert = "INSERT INTO BPPENNYAUTOBID_bids(auction, bidder, bid, bidwhen)//               VALUES($id, $user_id_, " . converttonum($_POST['bid']) . ", '$NOW')";//		
                      //		mysql_query($insert);//	}//	//update user's balance    //	$balance_ -= 1;//	$update = "UPDATE BPPENNYAUTOBID_users SET balance=$balance_//                  WHERE nick LIKE '" . addslashes($_SESSION['BPPENNYAUTOBID_LOGGED_IN_USERNAME']) . "' AND id=$user_id_";//	mysql_query($update);
                      do_bid($id,$user_id_,$_POST['bid']);
                      autobidProcessing($id);	// Save current F5 control number for next check	$_SESSION['f5_num1'] = $_POST['f5_num'];}
                      /** * NOTE: AUCTION AUTOEXTENSION */
                      $EXTSETTINGS = @mysql_fetch_array(@mysql_query("SELECT * FROM BPPENNYAUTOBID_auctionextension"));
                      if($EXTSETTINGS['status'] == 'enabled')
                      {
                      	$__END = mktime(substr($auctionends, 8, 2), substr($auctionends, 10, 2), substr($auctionends, 12, 2), substr($auctionends, 4, 2), substr($auctionends, 6, 2), substr($auctionends, 0, 4));
                      	if(($__END - $TIME) <= $EXTSETTINGS['timebefore'])
                      	{
                      		$auctionends = date("YmdHis", mktime(substr($auctionends, 8, 2), substr($auctionends, 10, 2), substr($auctionends, 12, 2) + $EXTSETTINGS['extend'], substr($auctionends, 4, 2), substr($auctionends, 6, 2), substr($auctionends, 0, 4)));
                      	}
                      	$query = "UPDATE BPPENNYAUTOBID_auctions set ends='$auctionends' WHERE id=" . intval($id);
                      	if(!mysql_query($query))
                      	{
                      		MySQLError($query);
                      		exit();
                      	}
                      }        // Generate new F5 control number$f5_num = getRandomInt(20);// Check for winner - find maximum bid$check = "SELECT bid, bidder, COUNT(bid) AS bid_count              FROM BPPENNYAUTOBID_bids              WHERE auction=$id GROUP BY bid ORDER BY bid DESC ";$check_result = mysql_query($check);$winner_bid = 0;$winner_bid_count = 0;$winner_id = 0;if($check_row = mysql_fetch_array($check_result)){	$winner_bid = $check_row['bid'];	$winner_bid_count = $check_row['bid_count'];	if($winner_bid_count == 1) $winner_id = $check_row['bidder'];}// Find the current winner of the auction
                      while($check_row = mysql_fetch_array($check_result)){	// Find out if the bid is unique        
                      	if($check_row['bid_count'] == 1)	{		// If this unique bid is the highest - it is a winner
                      		if($check_row['bid'] > $winner_bid)		{			$winner_id = $check_row['bidder'];			$winner_bid = $check_row['bid'];		}	}}$MSG_WINNER = "";$is_winner = false;if($winner_id == $_SESSION['BPPENNYAUTOBID_LOGGED_IN']){	$is_winner = true; // Current user is the winner}// Show message about current bid if it's winner bid, its state etc...switch($_POST['bid_type']){	case "simple":		$result3 = mysql_query($check);		$is_unique = false;		while($row3 = mysql_fetch_array($result3))		{			if($row3['bid_count'] == 1 && $row3['bid'] == $_POST['bid'])			{				$is_unique = true;				break;			}		}		if($_POST['bid'] == $winner_bid && $is_winner)		{ //This bid is winner		$MSG_WINNER = $MSG_31_0053;		}else		{			if($is_unique == true)			{				$MSG_WINNER = $MSG_31_0054;				if($is_winner == true)				{					$MSG_WINNER .= str_replace("<winner_bid>", $winner_bid, $MSG_31_0057);				}			}else			{				$MSG_WINNER = $MSG_31_0055;				if($is_winner == true)				{					$MSG_WINNER .= str_replace("<winner_bid>", $winner_bid, $MSG_31_0057);				}			}		}		break;	default:	break;}
                      #########################  Next Bid    #########################################################//$query = "select max(bid) AS maxbid, bidder FROM BPPENNYAUTOBID_bids WHERE auction=" . intval($id) . " GROUP BY auction, bidder ORDER BY maxbid DESC";//
                      //$result_bids = mysql_query($query);//$customincrement = mysql_result($result, 0, "increment");//$max_bid = mysql_result($result_bids, 0, "maxbid");//
                      ////echo '$max_bid='.$max_bid;//$minimum_bid = mysql_result($result, 0, "minimum_bid");//if($max_bid == 0)//{//	$MAX_BID = $minimum_bid;//	//// Added by Yosi 22 Jul 2009 - consider if auction starts with some value//	$max_bid = $minimum_bid;//}else//{//	$MAX_BID = $max_bid;//}///* Get bid increment for current bid and calculate minimum bid *///
                      //$query = "SELECT increment FROM BPPENNYAUTOBID_increments WHERE " . "((low <= $MAX_BID AND high >= $MAX_BID) OR " . "(low < $MAX_BID AND high < $MAX_BID)) ORDER BY increment DESC";//
                      ////echo "<div style='display:none;'>sql:<br>";////echo "$query</div>";//
                      //$result_incr = mysql_query($query);//if(mysql_num_rows($result_incr) != 0)//{//	$increment = mysql_result($result_incr, 0, "increment");//}//if($customincrement > 0)//{	//	$increment = $customincrement;//}//if($max_bid == 0 || $atype == 2)//{//	$next_bid = $minimum_bid;//}else//{	//	$next_bid = $max_bid + $increment;//}//$TPL_next_bid_value = $next_bid;
                      $TPL_next_bid_value = get_next_bid($id);##################################################################//if($is_winner==false){//   $MSG_WINNER .= $MSG_31_0056;//}$auction_type = $_POST['auction_type'];$type = $_POST['form_type'];$TPL_id = $id;// Show list of bids$auction_id = $id;
                      header("Location: item.php?id=".$id."&history=view#history");
                      ////include_once ("bid_list.php");//include_once "header.php";//include_once phpa_include("template_bid_result_php.html");//include_once "footer.php";//exit();
                      function get_HOW_MANY($auction_id)
                      {
                      	$how_many = "&nbsp;";
                      	if(isset($_SESSION["BPPENNYAUTOBID_LOGGED_IN"]))
                      	{
                      		$sql = "SELECT asi.offers
                                      FROM BPPENNYAUTOBID_auctions_signed asi
                                      INNER JOIN BPPENNYAUTOBID_auctions a ON asi.auction_id=a.id
                                      WHERE asi.user_id=" . $_SESSION["BPPENNYAUTOBID_LOGGED_IN"] . " AND
                                         asi.auction_id=" . $auction_id . " AND a.auction_type>1";
                      		$res = mysql_query($sql);
                      		if($res)
                      		{
                      			if(mysql_num_rows($res) > 0)
                      			{
                      				$row1 = mysql_fetch_array($res);
                      				$how_many = "Your number of offers available for this auction are: " . $row1['offers'];
                      			}
                      		}
                      	}
                      	return $how_many;
                      }
                      //--------------------------------------------------------------------------// gets random integer//--------------------------------------------------------------------------function getRandomInt($length = 20){	$template = "1234567890abcdefghijklmnopqrstuvwxyz";	//$template = "1234567890";	settype($template, "string");	settype($length, "integer");	settype($rndstring, "string");	settype($a, "integer");	settype($b, "integer");	for($a = 0; $a <= $length; $a++)	{		$b = rand(0, strlen($template) - 1);		$rndstring .= $template[$b];	}	return $rndstring;}function get_next_bid($auction_id) {
                      	
                      	if (intval($auction_id)>0) {
                      		$result = mysql_query("SELECT * FROM BPPENNYAUTOBID_auctions WHERE id=" . intval($auction_id));
                      		$result_bids = mysql_query("select max(bid) AS maxbid, bidder FROM BPPENNYAUTOBID_bids WHERE auction=" . intval($auction_id) . " GROUP BY auction, bidder ORDER BY maxbid DESC");
                      
                      		$customincrement = mysql_result($result, 0, "increment");
                      		$max_bid = mysql_result($result_bids, 0, "maxbid");
                      		$minimum_bid = mysql_result($result, 0, "minimum_bid");
                      		if($max_bid == 0) {
                      			$MAX_BID = $minimum_bid;
                      			//// Added by Yosi 22 Jul 2009 - consider if auction starts with some value
                      			$max_bid = $minimum_bid;
                      		}else
                      		{
                      			$MAX_BID = $max_bid;
                      		}
                      		/* Get bid increment for current bid and calculate minimum bid */
                      		
                      		$query = "SELECT increment FROM BPPENNYAUTOBID_increments WHERE " . "((low <= $MAX_BID AND high >= $MAX_BID) OR " . "(low < $MAX_BID AND high < $MAX_BID)) ORDER BY increment DESC";
                      		
                      		//echo "<div style='display:none;'>sql:<br>";
                      		//echo "$query</div>";
                      		
                      		$result_incr = mysql_query($query);
                      		if(mysql_num_rows($result_incr) != 0)
                      		{
                      			$increment = mysql_result($result_incr, 0, "increment");
                      		}
                      		if($customincrement > 0)
                      		{	
                      			$increment = $customincrement;
                      		}
                      		
                      		if($max_bid == 0 || $atype == 2)
                      		{
                      			$next_bid = $minimum_bid;
                      		}else
                      		{	
                      			$next_bid = $max_bid + $increment;
                      		}
                      		return $next_bid;
                      	} else {
                      		return 0;
                      	}
                      }
                      
                      function autobidProcessing($auction_id=0) {
                      	if (intval($auction_id)>0) {
                      		//do {
                      			$sql="SELECT
                      					BPPENNYAUTOBID_autobids.id,
                      					BPPENNYAUTOBID_autobids.bidder_id,
                      					BPPENNYAUTOBID_autobids.remained_bids,
                      					BPPENNYAUTOBID_autobids.max_amount,
                      					BPPENNYAUTOBID_users.balance
                      				FROM BPPENNYAUTOBID_autobids
                      				INNER JOIN BPPENNYAUTOBID_users ON BPPENNYAUTOBID_autobids.bidder_id=BPPENNYAUTOBID_users.id
                      				WHERE
                      					BPPENNYAUTOBID_autobids.auction_id='".$auction_id."'";
                      			$result=mysql_query($sql);
                      			//$return_flag=false;
                      			$bid_flag=false;
                      			while($row=mysql_fetch_array($result)) {
                      				if ($row['remained_bids']>0 && $row['max_amount']>get_next_bid($auction_id)) {
                      					if ($row['bidder_id']!=get_current_bidder_id($auction_id)) {
                      						if (do_bid($auction_id,$row['bidder_id'],get_next_bid($auction_id))) {
                      							mysql_query("UPDATE BPPENNYAUTOBID_autobids SET remained_bids=remained_bids-1 WHERE id='".$row['id']."'");
                      							$bid_flag=true;
                      						}
                      					}
                      				}
                      			}
                      		//} while ($bid_flag);
                      	}
                      }
                      
                      
                      function do_bid($auction_id,$user_id,$bid_value) {
                      	global $NOW;
                      	
                      	
                      	if (intval($auction_id)>0 && intval($user_id)>0 && $bid_value>0) {
                      		
                      		$result_b = mysql_query("SELECT id, balance FROM BPPENNYAUTOBID_users WHERE id='" .$user_id. "'");
                      		$bal_row = mysql_fetch_array($result_b);
                      		$balance = $bal_row['balance'];
                      		
                      		$sql="SELECT ends,bid_value,closed,w_seat FROM BPPENNYAUTOBID_auctions WHERE id='".$auction_id."'";
                              $result1=mysql_query($sql);
                              $ends = mysql_result($result1, 0, "ends");
                      		$closed = mysql_result($result1, 0, "closed");
                      		$w_seat=mysql_result($result1, 0, "w_seat");		
                      		if ($closed==0) {	
                      			if (($balance>0 && $w_seat==1)||($w_seat==2)) {
                      				if ((strtotime($ends)-strtotime($NOW)>=0) && (strtotime($ends)-strtotime($NOW)<=15)) {					//$new_ends=date("YmdHis",strtotime($NOW)+32);					//mysql_query("UPDATE BPPENNYAUTOBID_auctions SET jump30=1 WHERE id='".$auction_id."'");					//echo "UPDATE auctions SET ends='".$new_ends."' WHERE auction_id='".$auction_id."'";					$new_ends=date("YmdHis",strtotime($ends)+15-(strtotime($ends)-strtotime($NOW))+1);					mysql_query("UPDATE BPPENNYAUTOBID_auctions SET ends='".$new_ends."', jump30=0 WHERE id='".$auction_id."'");									}				if (strtotime($ends)-strtotime($NOW)>=0) {					$insert = "INSERT INTO BPPENNYAUTOBID_bids(auction, bidder, bid, bidwhen)
                      							   VALUES('" .$auction_id. ".','." .$user_id. ".','.".converttonum(get_next_bid($auction_id)). ".','." .$NOW. ".').";
                      						
                      					
                      					mysql_query($insert);
                      					
                      	
                      					if ($w_seat==1) {
                      						$balance -= 1;
                      						# $update = "UPDATE BPPENNYAUTOBID_users SET balance=".$balance."                                       
                                                                                                            WHERE id=".$user_id;
                      						
                      						mysql_query($update);					}					return true;				} else {					return false;				}
                      			} else {
                      				return false;	
                      			}
                      		} else {
                      			return false;
                      		}
                      	} else {
                      		return false;
                      	}
                      }
                      
                      function converttonum($convertnum){
                      	$bits = explode(",",$convertnum); // split input value up to allow checking
                         
                      	$first = strlen($bits[0]); // gets part before first comma (thousands/millions)
                      	$last = strlen($bits[1]); // gets part after first comma (thousands (or decimals if incorrectly used by user)
                         
                      	if ($last <3){ // checks for comma being used as decimal place
                      		$convertnum = str_replace(",",".",$convertnum);
                      	}
                      	else{ // assume comma is a thousands seperator, so remove it
                      		$convertnum = str_replace(",","",$convertnum);
                      	}
                         
                      	return $convertnum; 
                      } 
                      
                      function get_current_bidder_id($auction_id) {
                      	$sql = "SELECT bid, bidder, COUNT(bid) AS bid_count
                                    FROM BPPENNYAUTOBID_bids
                                    WHERE auction=".$auction_id." GROUP BY bid ORDER BY bid DESC ";
                      	$result = mysql_query($sql);
                      	if ($row1=mysql_fetch_array($result)) {
                      		return $row1['bidder'];
                      	} else {
                      		return 0;
                      	}
                      }
                      ?>
                      Last edited by Topbidder; Jul 11 '10, 05:49 PM. Reason: putting line 167 in

                      Comment

                      • TheServant
                        Recognized Expert Top Contributor
                        • Feb 2008
                        • 1168

                        #12
                        What is # doing there?

                        Comment

                        • Samishii23
                          New Member
                          • Sep 2009
                          • 246

                          #13
                          If I may ask... Whats with all the commented out lines? This is not good practice to have all these commented out lines. It makes for reading / updating code a pain for anyone, even the one who originally wrote it all.

                          My suggestion is make a new file and copy paste all this to that file and then take out all the commented out stuff that your obviously not using right now, and clean it up.

                          Comment

                          • Topbidder
                            New Member
                            • Jul 2010
                            • 11

                            #14
                            @ Samishii23 Samishii23

                            I didn't take anything out that what i couldn't figure out the software i bought it and as i posted it was how i got it see to have so many errors and bugs in it i thought it was very off and when i asked the company what they done to fix it once they wouldn't tell ,me so i started to look at the code to try to figure it out in the end with the help of some here i did figure it out

                            Awesome thank you all for your help i got it all fixed now the site is open for registration without bugs or glitches come check them out



                            without all your help i wouldnt been able to get the bugs out many thanks again

                            Comment

                            Working...