By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,077 Members | 2,121 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,077 IT Pros & Developers. It's quick & easy.

Parse error: syntax error, unexpected

Topbidder
P: 11
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(get_next_bid($auction_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


Expand|Select|Wrap|Line Numbers
  1. <?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);
  2. #// #################################################// 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();}
  3. if(!$id) $id = $_REQUEST[id];
  4. if(!$bid) $bid = $_REQUEST[bid];
  5. $auction_type = $_POST['auction_type'];
  6. $type = $_POST['form_type'];
  7. $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();}
  8. # // ###############################    # 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']) . "'";
  9. //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')";//        
  10. //        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);
  11. do_bid($id,$user_id_,$_POST['bid']);
  12. autobidProcessing($id);    // Save current F5 control number for next check    $_SESSION['f5_num1'] = $_POST['f5_num'];}
  13. /** * NOTE: AUCTION AUTOEXTENSION */
  14. $EXTSETTINGS = @mysql_fetch_array(@mysql_query("SELECT * FROM BPPENNYAUTOBID_auctionextension"));
  15. if($EXTSETTINGS['status'] == 'enabled')
  16. {
  17.     $__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));
  18.     if(($__END - $TIME) <= $EXTSETTINGS['timebefore'])
  19.     {
  20.         $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)));
  21.     }
  22.     $query = "UPDATE BPPENNYAUTOBID_auctions set ends='$auctionends' WHERE id=" . intval($id);
  23.     if(!mysql_query($query))
  24.     {
  25.         MySQLError($query);
  26.         exit();
  27.     }
  28. }        // 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
  29. while($check_row = mysql_fetch_array($check_result)){    // Find out if the bid is unique        
  30.     if($check_row['bid_count'] == 1)    {        // If this unique bid is the highest - it is a winner
  31.         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;}
  32. #########################  Next Bid    #########################################################//$query = "select max(bid) AS maxbid, bidder FROM BPPENNYAUTOBID_bids WHERE auction=" . intval($id) . " GROUP BY auction, bidder ORDER BY maxbid DESC";//
  33. //$result_bids = mysql_query($query);//$customincrement = mysql_result($result, 0, "increment");//$max_bid = mysql_result($result_bids, 0, "maxbid");//
  34. ////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 *///
  35. //$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";//
  36. ////echo "<div style='display:none;'>sql:<br>";////echo "$query</div>";//
  37. //$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;
  38. $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;
  39. header("Location: item.php?id=".$id."&history=view#history");
  40. ////include_once ("bid_list.php");//include_once "header.php";//include_once phpa_include("template_bid_result_php.html");//include_once "footer.php";//exit();
  41. function get_HOW_MANY($auction_id)
  42. {
  43.     $how_many = "&nbsp;";
  44.     if(isset($_SESSION["BPPENNYAUTOBID_LOGGED_IN"]))
  45.     {
  46.         $sql = "SELECT asi.offers
  47.                 FROM BPPENNYAUTOBID_auctions_signed asi
  48.                 INNER JOIN BPPENNYAUTOBID_auctions a ON asi.auction_id=a.id
  49.                 WHERE asi.user_id=" . $_SESSION["BPPENNYAUTOBID_LOGGED_IN"] . " AND
  50.                    asi.auction_id=" . $auction_id . " AND a.auction_type>1";
  51.         $res = mysql_query($sql);
  52.         if($res)
  53.         {
  54.             if(mysql_num_rows($res) > 0)
  55.             {
  56.                 $row1 = mysql_fetch_array($res);
  57.                 $how_many = "Your number of offers available for this auction are: " . $row1['offers'];
  58.             }
  59.         }
  60.     }
  61.     return $how_many;
  62. }
  63. //--------------------------------------------------------------------------// 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) {
  64.  
  65.     if (intval($auction_id)>0) {
  66.         $result = mysql_query("SELECT * FROM BPPENNYAUTOBID_auctions WHERE id=" . intval($auction_id));
  67.         $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");
  68.  
  69.         $customincrement = mysql_result($result, 0, "increment");
  70.         $max_bid = mysql_result($result_bids, 0, "maxbid");
  71.         $minimum_bid = mysql_result($result, 0, "minimum_bid");
  72.         if($max_bid == 0) {
  73.             $MAX_BID = $minimum_bid;
  74.             //// Added by Yosi 22 Jul 2009 - consider if auction starts with some value
  75.             $max_bid = $minimum_bid;
  76.         }else
  77.         {
  78.             $MAX_BID = $max_bid;
  79.         }
  80.         /* Get bid increment for current bid and calculate minimum bid */
  81.  
  82.         $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";
  83.  
  84.         //echo "<div style='display:none;'>sql:<br>";
  85.         //echo "$query</div>";
  86.  
  87.         $result_incr = mysql_query($query);
  88.         if(mysql_num_rows($result_incr) != 0)
  89.         {
  90.             $increment = mysql_result($result_incr, 0, "increment");
  91.         }
  92.         if($customincrement > 0)
  93.         {    
  94.             $increment = $customincrement;
  95.         }
  96.  
  97.         if($max_bid == 0 || $atype == 2)
  98.         {
  99.             $next_bid = $minimum_bid;
  100.         }else
  101.         {    
  102.             $next_bid = $max_bid + $increment;
  103.         }
  104.         return $next_bid;
  105.     } else {
  106.         return 0;
  107.     }
  108. }
  109.  
  110. function autobidProcessing($auction_id=0) {
  111.     if (intval($auction_id)>0) {
  112.         //do {
  113.             $sql="SELECT
  114.                     BPPENNYAUTOBID_autobids.id,
  115.                     BPPENNYAUTOBID_autobids.bidder_id,
  116.                     BPPENNYAUTOBID_autobids.remained_bids,
  117.                     BPPENNYAUTOBID_autobids.max_amount,
  118.                     BPPENNYAUTOBID_users.balance
  119.                 FROM BPPENNYAUTOBID_autobids
  120.                 INNER JOIN BPPENNYAUTOBID_users ON BPPENNYAUTOBID_autobids.bidder_id=BPPENNYAUTOBID_users.id
  121.                 WHERE
  122.                     BPPENNYAUTOBID_autobids.auction_id='".$auction_id."'";
  123.             $result=mysql_query($sql);
  124.             //$return_flag=false;
  125.             $bid_flag=false;
  126.             while($row=mysql_fetch_array($result)) {
  127.                 if ($row['remained_bids']>0 && $row['max_amount']>get_next_bid($auction_id)) {
  128.                     if ($row['bidder_id']!=get_current_bidder_id($auction_id)) {
  129.                         if (do_bid($auction_id,$row['bidder_id'],get_next_bid($auction_id))) {
  130.                             mysql_query("UPDATE BPPENNYAUTOBID_autobids SET remained_bids=remained_bids-1 WHERE id='".$row['id']."'");
  131.                             $bid_flag=true;
  132.                         }
  133.                     }
  134.                 }
  135.             }
  136.         //} while ($bid_flag);
  137.     }
  138. }
  139.  
  140.  
  141. function do_bid($auction_id,$user_id,$bid_value) {
  142.     global $NOW;
  143.  
  144.  
  145.     if (intval($auction_id)>0 && intval($user_id)>0 && $bid_value>0) {
  146.  
  147.         $result_b = mysql_query("SELECT id, balance FROM BPPENNYAUTOBID_users WHERE id='" .$user_id. "'");
  148.         $bal_row = mysql_fetch_array($result_b);
  149.         $balance = $bal_row['balance'];
  150.  
  151.         $sql="SELECT ends,bid_value,closed,w_seat FROM BPPENNYAUTOBID_auctions WHERE id='".$auction_id."'";
  152.         $result1=mysql_query($sql);
  153.         $ends = mysql_result($result1, 0, "ends");
  154.         $closed = mysql_result($result1, 0, "closed");
  155.         $w_seat=mysql_result($result1, 0, "w_seat");        
  156.         if ($closed==0) {    
  157.             if (($balance>0 && $w_seat==1)||($w_seat==2)) {
  158.                 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)
  159.                                VALUES('" .$auction_id. "','" .$user_id.  "','" .converttonum(get_next_bid($auction_id)). "','" .$NOW. "')";
  160.  
  161.  
  162.                     mysql_query($insert);
  163.  
  164.  
  165.                     if ($w_seat==1) {
  166.                         $balance -= 1;
  167.                         $update = "UPDATE BPPENNYAUTOBID_users SET balance=".$balance."
  168.                                       WHERE id=".$user_id;
  169.  
  170.                         mysql_query($update);                    }                    return true;                } else {                    return false;                }
  171.             } else {
  172.                 return false;    
  173.             }
  174.         } else {
  175.             return false;
  176.         }
  177.     } else {
  178.         return false;
  179.     }
  180. }
  181.  
  182. function converttonum($convertnum){
  183.     $bits = explode(",",$convertnum); // split input value up to allow checking
  184.  
  185.     $first = strlen($bits[0]); // gets part before first comma (thousands/millions)
  186.     $last = strlen($bits[1]); // gets part after first comma (thousands (or decimals if incorrectly used by user)
  187.  
  188.     if ($last <3){ // checks for comma being used as decimal place
  189.         $convertnum = str_replace(",",".",$convertnum);
  190.     }
  191.     else{ // assume comma is a thousands seperator, so remove it
  192.         $convertnum = str_replace(",","",$convertnum);
  193.     }
  194.  
  195.     return $convertnum; 
  196.  
  197. function get_current_bidder_id($auction_id) {
  198.     $sql = "SELECT bid, bidder, COUNT(bid) AS bid_count
  199.               FROM BPPENNYAUTOBID_bids
  200.               WHERE auction=".$auction_id." GROUP BY bid ORDER BY bid DESC ";
  201.     $result = mysql_query($sql);
  202.     if ($row1=mysql_fetch_array($result)) {
  203.         return $row1['bidder'];
  204.     } else {
  205.         return 0;
  206.     }
  207. }
  208. ?>
Jul 9 '10 #1

✓ answered by JKing

@TheServant
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.
Expand|Select|Wrap|Line Numbers
  1. $update = "UPDATE BPPENNYAUTOBID_users SET balance=".$balance."                                       
  2. WHERE id=".$user_id;
  3.  
Whitespace and line breaks are ignored by PHP

Share this Question
Share on Google+
13 Replies


JKing
Expert 100+
P: 1,206
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.
Jul 9 '10 #2

Topbidder
P: 11
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
Jul 9 '10 #3

TheServant
Expert 100+
P: 1,168
The problem is in:
Expand|Select|Wrap|Line Numbers
  1. $insert = "INSERT INTO BPPENNYAUTOBID_bids(auction, bidder, bid, bidwhen) VALUES('" .$auction_id. "','" .$user_id.  "','" .converttonum(get_next_bid($auction_id)). "','" .$NOW. "')";
Should be:
Expand|Select|Wrap|Line Numbers
  1. $temp_num = converttonum(get_next_bid($auction_id));
  2. $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:
Expand|Select|Wrap|Line Numbers
  1. VALUES('" .$auction_id. "','" .$user_id. "','"
  2. .converttonum(get_next_bid($auction_id)). "','" .$NOW. "')";
  3. // SHOULD BE
  4. VALUES('" .$auction_id. ".','." .$user_id. ".','."
  5. .converttonum(get_next_bid($auction_id)). ".','." .$NOW. ".').";
See all the extra .'s? But as I say, you don't need all that concatenation.
Jul 10 '10 #4

JKing
Expert 100+
P: 1,206
@TheServant
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(fullstops) 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.
Jul 10 '10 #5

TheServant
Expert 100+
P: 1,168
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.
Jul 10 '10 #6

Topbidder
P: 11
Awesome thanks i will do that and go over the who code
Jul 10 '10 #7

JKing
Expert 100+
P: 1,206
@TheServant
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.
Expand|Select|Wrap|Line Numbers
  1. $update = "UPDATE BPPENNYAUTOBID_users SET balance=".$balance."                                       
  2. WHERE id=".$user_id;
  3.  
Whitespace and line breaks are ignored by PHP
Jul 10 '10 #8

Topbidder
P: 11
wow i changed that now i got this lol
this is the site i have the error on

http://www.top-bidder.com/bid2

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
Expand|Select|Wrap|Line Numbers
  1. <?
  2. include_once "./includes/config.inc.php";
  3. #// Run cron according to SETTINGS
  4. if($SETTINGS['cron'] == 2)
  5. {
  6.     include_once "cron.php";
  7. }
  8. include_once $include_path . "auction_types.inc.php";
  9. include_once $include_path . "dates.inc.php";
  10. $TIME = mktime(date("H") + $SETTINGS['timecorrection'], date("i"), date("s"), date("m"), date("d"), date("Y"));
  11. $NOW = date("YmdHis", $TIME);
  12.  
  13. #// ################################################
  14. #// Is the seller logged in?
  15. if(!isset($_SESSION['BPPENNYAUTOBID_LOGGED_IN']))
  16. {
  17.     $REDIRECT_AFTER_LOGIN = "index.php";
  18.     $_SESSION['REDIRECT_AFTER_LOGIN'] = $REDIRECT_AFTER_LOGIN;
  19.     Header("Location: user_login.php");
  20.     exit();
  21. }
  22.  
  23.  
  24. if(!$id) $id = $_REQUEST[id];
  25.  
  26. if(!$bid) $bid = $_REQUEST[bid];
  27.  
  28. $auction_type = $_POST['auction_type'];
  29.  
  30. $type = $_POST['form_type'];
  31.  
  32. $TPL_id = $id;
  33. /** first check if valid auction ID passed */
  34. $result = mysql_query("SELECT * FROM BPPENNYAUTOBID_auctions WHERE id=" . intval($id));
  35. // SQL error
  36. if(!$result)
  37. {
  38.     MySQLError($query);
  39.     exit();
  40. }
  41. $Data = mysql_fetch_array($result);
  42. $n = mysql_num_rows($result);
  43. $TPL_title = htmlspecialchars($Data['title']);
  44. $TPL_id_value = $id;
  45. $TPL_auctions_list_value = "";
  46. $query = "select bid,id from BPPENNYAUTOBID_bids where auction=\"" . intval($id) . "\" ORDER BY id DESC";
  47. $result___ = mysql_query($query);
  48. if(mysql_num_rows($result___) > 0)
  49. {
  50.     $ARETHEREBIDS = "<A HREF=\"" . $SETTINGS['siteurl'] . "item.php?id=$id&history=view#history\">$MSG_105</A>";
  51.     $CURRENTBID_ID = mysql_result($result___, 0, "id");
  52. }else
  53. {
  54.     unset($TPL_BIDS_value);
  55. }
  56. # // ###############################
  57. // $ITEM = mysql_fetch_array($result);
  58. // such auction does not exist, so exit
  59. if($n == 0)
  60. {
  61.     include_once ("header.php");
  62.     $TPL_errmsg = $ERR_606;
  63.     include_once (phpa_include("template_bid_php.html"));
  64.     include_once ("footer.php");
  65.     exit();
  66. }
  67.  
  68. # // ###############################    
  69. # check if the user has enough money on his account
  70. $bid_sum = 0;
  71. //echo "<pre>Data<br>";
  72. //print_r($Data);
  73. //echo "</pre>";
  74. // Retrieve bid value (one bid cost)
  75. if(ereg("^(\+?((([0-9]+(\.)?)|([0-9]*\.[0-9]+))([eE][+-]?[0-9]+)?))$", $Data['bid_value']))
  76. {
  77.     $bid_value = $Data['bid_value'];
  78. }else
  79.     $bid_value = 2;
  80. if($_POST['bid_type'] == 'simple')
  81. {
  82.     $bid_sum = $bid_value;
  83. }
  84. $query = "SELECT id, balance FROM BPPENNYAUTOBID_users WHERE nick='" . addslashes($_SESSION['BPPENNYAUTOBID_LOGGED_IN_USERNAME']) . "'";
  85.  
  86. //echo "bid_sum = $bid_sum<br>sql: $query";
  87. $result_b = mysql_query($query);
  88. $bal_row = mysql_fetch_array($result_b);
  89. $balance_ = $bal_row['balance'];
  90. $user_id_ = $bal_row['id'];
  91. // the user has not enough money    
  92. if($balance_ < 1)
  93. {
  94.     include_once ("header.php");
  95.     $TPL_errmsg = $ERR_32_0001;
  96.     $bidH = $bid_sum;
  97.     // Show list of bids
  98.     $auction_id = $id;
  99.     include_once ("bid_list.php");
  100.     include_once (phpa_include("template_bid_php.html"));
  101.     include_once ("footer.php");
  102.     exit();
  103. }
  104. $auctiondate = $Data['starts'];
  105. $auctionends = $Data['ends'];
  106. $item_title = $Data["title"];
  107. $item_description = $Data["description"];
  108. // check if auction isn't closed    
  109. $AuctionIsClosed = false;
  110. $closed = intval($Data["closed"]);
  111. $c = $Data["ends"];
  112. 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;
  113. if(($closed == 1) || ($AuctionIsClosed) || ($Data['suspended'] == 1))
  114. {
  115.     include_once ("header.php");
  116.     $TPL_errmsg = $ERR_614;
  117.     // Show list of bids
  118.     $auction_id = $id;
  119.     include_once ("bid_list.php");
  120.     include_once (phpa_include("template_bid_php.html"));
  121.     include_once ("footer.php");
  122.     exit();
  123. }
  124. $insert = "";
  125. // Check if the user pressed F5: if no - processing the bid, if yes - not processing
  126. if($_POST['f5_num'] != $_SESSION['f5_num1'])
  127. {
  128.     // Insert records of each bid (one - if simple, multiple - if 'range')
  129. //    if($_POST['bid_type'] == 'simple')
  130. //    {
  131. //        $insert = "INSERT INTO BPPENNYAUTOBID_bids(auction, bidder, bid, bidwhen)
  132. //               VALUES($id, $user_id_, " . converttonum($_POST['bid']) . ", '$NOW')";
  133. //        
  134. //        mysql_query($insert);
  135. //    }
  136. //    //update user's balance    
  137. //    $balance_ -= 1;
  138. //    $update = "UPDATE BPPENNYAUTOBID_users SET balance=$balance_
  139. //                  WHERE nick LIKE '" . addslashes($_SESSION['BPPENNYAUTOBID_LOGGED_IN_USERNAME']) . "' AND id=$user_id_";
  140. //    mysql_query($update);
  141. do_bid($id,$user_id_,$_POST['bid']);
  142. autobidProcessing($id);
  143.     // Save current F5 control number for next check
  144.     $_SESSION['f5_num1'] = $_POST['f5_num'];
  145. }
  146.  
  147.  
  148. /**
  149.  * NOTE: AUCTION AUTOEXTENSION
  150.  */
  151. $EXTSETTINGS = @mysql_fetch_array(@mysql_query("SELECT * FROM BPPENNYAUTOBID_auctionextension"));
  152. if($EXTSETTINGS['status'] == 'enabled')
  153. {
  154.     $__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));
  155.     if(($__END - $TIME) <= $EXTSETTINGS['timebefore'])
  156.     {
  157.         $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)));
  158.     }
  159.     $query = "UPDATE BPPENNYAUTOBID_auctions set ends='$auctionends' WHERE id=" . intval($id);
  160.     if(!mysql_query($query))
  161.     {
  162.         MySQLError($query);
  163.         exit();
  164.     }
  165. }
  166.  
  167.  
  168. // Generate new F5 control number
  169. $f5_num = getRandomInt(20);
  170. // Check for winner - find maximum bid
  171. $check = "SELECT bid, bidder, COUNT(bid) AS bid_count
  172.               FROM BPPENNYAUTOBID_bids
  173.               WHERE auction=$id GROUP BY bid ORDER BY bid DESC ";
  174. $check_result = mysql_query($check);
  175. $winner_bid = 0;
  176. $winner_bid_count = 0;
  177. $winner_id = 0;
  178. if($check_row = mysql_fetch_array($check_result))
  179. {
  180.     $winner_bid = $check_row['bid'];
  181.     $winner_bid_count = $check_row['bid_count'];
  182.     if($winner_bid_count == 1) $winner_id = $check_row['bidder'];
  183. }
  184. // Find the current winner of the auction
  185.  
  186. while($check_row = mysql_fetch_array($check_result))
  187. {
  188.     // Find out if the bid is unique        
  189.  
  190.     if($check_row['bid_count'] == 1)
  191.     {
  192.         // If this unique bid is the highest - it is a winner
  193.  
  194.         if($check_row['bid'] > $winner_bid)
  195.         {
  196.             $winner_id = $check_row['bidder'];
  197.             $winner_bid = $check_row['bid'];
  198.         }
  199.     }
  200. }
  201. $MSG_WINNER = "";
  202. $is_winner = false;
  203. if($winner_id == $_SESSION['BPPENNYAUTOBID_LOGGED_IN'])
  204. {
  205.     $is_winner = true; // Current user is the winner
  206. }
  207. // Show message about current bid if it's winner bid, its state etc...
  208. switch($_POST['bid_type'])
  209. {
  210.     case "simple":
  211.         $result3 = mysql_query($check);
  212.         $is_unique = false;
  213.         while($row3 = mysql_fetch_array($result3))
  214.         {
  215.             if($row3['bid_count'] == 1 && $row3['bid'] == $_POST['bid'])
  216.             {
  217.                 $is_unique = true;
  218.                 break;
  219.             }
  220.         }
  221.         if($_POST['bid'] == $winner_bid && $is_winner)
  222.         { //This bid is winner
  223.         $MSG_WINNER = $MSG_31_0053;
  224.         }else
  225.         {
  226.             if($is_unique == true)
  227.             {
  228.                 $MSG_WINNER = $MSG_31_0054;
  229.                 if($is_winner == true)
  230.                 {
  231.                     $MSG_WINNER .= str_replace("<winner_bid>", $winner_bid, $MSG_31_0057);
  232.                 }
  233.             }else
  234.             {
  235.                 $MSG_WINNER = $MSG_31_0055;
  236.                 if($is_winner == true)
  237.                 {
  238.                     $MSG_WINNER .= str_replace("<winner_bid>", $winner_bid, $MSG_31_0057);
  239.                 }
  240.             }
  241.         }
  242.         break;
  243.     default:
  244.     break;
  245. }
  246.  
  247. #########################  Next Bid    #########################################################
  248. //$query = "select max(bid) AS maxbid, bidder FROM BPPENNYAUTOBID_bids WHERE auction=" . intval($id) . " GROUP BY auction, bidder ORDER BY maxbid DESC";
  249. //
  250. //$result_bids = mysql_query($query);
  251. //$customincrement = mysql_result($result, 0, "increment");
  252. //$max_bid = mysql_result($result_bids, 0, "maxbid");
  253. //
  254. ////echo '$max_bid='.$max_bid;
  255. //$minimum_bid = mysql_result($result, 0, "minimum_bid");
  256. //if($max_bid == 0)
  257. //{
  258. //    $MAX_BID = $minimum_bid;
  259. //    //// Added by Yosi 22 Jul 2009 - consider if auction starts with some value
  260. //    $max_bid = $minimum_bid;
  261. //}else
  262. //{
  263. //    $MAX_BID = $max_bid;
  264. //}
  265. ///* Get bid increment for current bid and calculate minimum bid */
  266. //
  267. //$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";
  268. //
  269. ////echo "<div style='display:none;'>sql:<br>";
  270. ////echo "$query</div>";
  271. //
  272. //$result_incr = mysql_query($query);
  273. //if(mysql_num_rows($result_incr) != 0)
  274. //{
  275. //    $increment = mysql_result($result_incr, 0, "increment");
  276. //}
  277. //if($customincrement > 0)
  278. //{    
  279. //    $increment = $customincrement;
  280. //}
  281. //if($max_bid == 0 || $atype == 2)
  282. //{
  283. //    $next_bid = $minimum_bid;
  284. //}else
  285. //{    
  286. //    $next_bid = $max_bid + $increment;
  287. //}
  288. //$TPL_next_bid_value = $next_bid;
  289. $TPL_next_bid_value = get_next_bid($id);
  290. ##################################################################
  291. //if($is_winner==false){
  292. //   $MSG_WINNER .= $MSG_31_0056;
  293. //}
  294. $auction_type = $_POST['auction_type'];
  295. $type = $_POST['form_type'];
  296. $TPL_id = $id;
  297. // Show list of bids
  298. $auction_id = $id;
  299. header("Location: item.php?id=".$id."&history=view#history");
  300. //
  301. //include_once ("bid_list.php");
  302. //include_once "header.php";
  303. //include_once phpa_include("template_bid_result_php.html");
  304. //include_once "footer.php";
  305. //exit();
  306.  
  307. function get_HOW_MANY($auction_id)
  308. {
  309.     $how_many = "&nbsp;";
  310.     if(isset($_SESSION["BPPENNYAUTOBID_LOGGED_IN"]))
  311.     {
  312.         $sql = "SELECT asi.offers
  313.                 FROM BPPENNYAUTOBID_auctions_signed asi
  314.                 INNER JOIN BPPENNYAUTOBID_auctions a ON asi.auction_id=a.id
  315.                 WHERE asi.user_id=" . $_SESSION["BPPENNYAUTOBID_LOGGED_IN"] . " AND
  316.                    asi.auction_id=" . $auction_id . " AND a.auction_type>1";
  317.         $res = mysql_query($sql);
  318.         if($res)
  319.         {
  320.             if(mysql_num_rows($res) > 0)
  321.             {
  322.                 $row1 = mysql_fetch_array($res);
  323.                 $how_many = "Your number of offers available for this auction are: " . $row1['offers'];
  324.             }
  325.         }
  326.     }
  327.     return $how_many;
  328. }
  329.  
  330. //--------------------------------------------------------------------------
  331. // gets random integer
  332. //--------------------------------------------------------------------------
  333. function getRandomInt($length = 20)
  334. {
  335.     $template = "1234567890abcdefghijklmnopqrstuvwxyz";
  336.     //$template = "1234567890";
  337.     settype($template, "string");
  338.     settype($length, "integer");
  339.     settype($rndstring, "string");
  340.     settype($a, "integer");
  341.     settype($b, "integer");
  342.     for($a = 0; $a <= $length; $a++)
  343.     {
  344.         $b = rand(0, strlen($template) - 1);
  345.         $rndstring .= $template[$b];
  346.     }
  347.     return $rndstring;
  348. }
  349. function get_next_bid($auction_id) {
  350.  
  351.     if (intval($auction_id)>0) {
  352.         $result = mysql_query("SELECT * FROM BPPENNYAUTOBID_auctions WHERE id=" . intval($auction_id));
  353.         $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");
  354.  
  355.         $customincrement = mysql_result($result, 0, "increment");
  356.         $max_bid = mysql_result($result_bids, 0, "maxbid");
  357.         $minimum_bid = mysql_result($result, 0, "minimum_bid");
  358.         if($max_bid == 0) {
  359.             $MAX_BID = $minimum_bid;
  360.             //// Added by Yosi 22 Jul 2009 - consider if auction starts with some value
  361.             $max_bid = $minimum_bid;
  362.         }else
  363.         {
  364.             $MAX_BID = $max_bid;
  365.         }
  366.         /* Get bid increment for current bid and calculate minimum bid */
  367.  
  368.         $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";
  369.  
  370.         //echo "<div style='display:none;'>sql:<br>";
  371.         //echo "$query</div>";
  372.  
  373.         $result_incr = mysql_query($query);
  374.         if(mysql_num_rows($result_incr) != 0)
  375.         {
  376.             $increment = mysql_result($result_incr, 0, "increment");
  377.         }
  378.         if($customincrement > 0)
  379.         {    
  380.             $increment = $customincrement;
  381.         }
  382.  
  383.         if($max_bid == 0 || $atype == 2)
  384.         {
  385.             $next_bid = $minimum_bid;
  386.         }else
  387.         {    
  388.             $next_bid = $max_bid + $increment;
  389.         }
  390.         return $next_bid;
  391.     } else {
  392.         return 0;
  393.     }
  394. }
  395.  
  396. function autobidProcessing($auction_id=0) {
  397.     if (intval($auction_id)>0) {
  398.         //do {
  399.             $sql="SELECT
  400.                     BPPENNYAUTOBID_autobids.id,
  401.                     BPPENNYAUTOBID_autobids.bidder_id,
  402.                     BPPENNYAUTOBID_autobids.remained_bids,
  403.                     BPPENNYAUTOBID_autobids.max_amount,
  404.                     BPPENNYAUTOBID_users.balance
  405.                 FROM BPPENNYAUTOBID_autobids
  406.                 INNER JOIN BPPENNYAUTOBID_users ON BPPENNYAUTOBID_autobids.bidder_id=BPPENNYAUTOBID_users.id
  407.                 WHERE
  408.                     BPPENNYAUTOBID_autobids.auction_id='".$auction_id."'";
  409.             $result=mysql_query($sql);
  410.             //$return_flag=false;
  411.             $bid_flag=false;
  412.             while($row=mysql_fetch_array($result)) {
  413.                 if ($row['remained_bids']>0 && $row['max_amount']>get_next_bid($auction_id)) {
  414.                     if ($row['bidder_id']!=get_current_bidder_id($auction_id)) {
  415.                         if (do_bid($auction_id,$row['bidder_id'],get_next_bid($auction_id))) {
  416.                             mysql_query("UPDATE BPPENNYAUTOBID_autobids SET remained_bids=remained_bids-1 WHERE id='".$row['id']."'");
  417.                             $bid_flag=true;
  418.                         }
  419.                     }
  420.                 }
  421.             }
  422.         //} while ($bid_flag);
  423.     }
  424. }
  425.  
  426.  
  427. function do_bid($auction_id,$user_id,$bid_value) {
  428.     global $NOW;
  429.  
  430.  
  431.     if (intval($auction_id)>0 && intval($user_id)>0 && $bid_value>0) {
  432.  
  433.         $result_b = mysql_query("SELECT id, balance FROM BPPENNYAUTOBID_users WHERE id='" .$user_id. "'");
  434.         $bal_row = mysql_fetch_array($result_b);
  435.         $balance = $bal_row['balance'];
  436.  
  437.         $sql="SELECT ends,bid_value,closed,w_seat FROM BPPENNYAUTOBID_auctions WHERE id='".$auction_id."'";
  438.         $result1=mysql_query($sql);
  439.         $ends = mysql_result($result1, 0, "ends");
  440.         $closed = mysql_result($result1, 0, "closed");
  441.         $w_seat=mysql_result($result1, 0, "w_seat");
  442.  
  443.         if ($closed==0) {    
  444.             if (($balance>0 && $w_seat==1)||($w_seat==2)) {
  445.                 if ((strtotime($ends)-strtotime($NOW)>=0) && (strtotime($ends)-strtotime($NOW)<=15)) {
  446.                     //$new_ends=date("YmdHis",strtotime($NOW)+32);
  447.                     //mysql_query("UPDATE BPPENNYAUTOBID_auctions SET jump30=1 WHERE id='".$auction_id."'");
  448.                     //echo "UPDATE auctions SET ends='".$new_ends."' WHERE auction_id='".$auction_id."'";
  449.                     $new_ends=date("YmdHis",strtotime($ends)+15-(strtotime($ends)-strtotime($NOW))+1);
  450.                     mysql_query("UPDATE BPPENNYAUTOBID_auctions SET ends='".$new_ends."', jump30=0 WHERE id='".$auction_id."'");
  451.  
  452.                 }
  453.                 if (strtotime($ends)-strtotime($NOW)>=0) {
  454.                     $insert = "INSERT INTO BPPENNYAUTOBID_bids(auction, bidder, bid, bidwhen)
  455.                                VALUES('" .$auction_id. "','" .$user_id. "','" .converttonum(get_next_bid($auction_id)). "','" .$NOW. "')";
  456.  
  457.  
  458.                     mysql_query($insert);
  459.  
  460.  
  461.                     if ($w_seat==1) {
  462.                         $balance -= 1;
  463.                         $update = "UPDATE BPPENNYAUTOBID_users SET balance=".$balance."
  464.                                       WHERE id=".$user_id;
  465.  
  466.                         mysql_query($update);
  467.                     }
  468.                     return true;
  469.                 } else {
  470.                     return false;
  471.                 }
  472.             } else {
  473.                 return false;    
  474.             }
  475.         } else {
  476.             return false;
  477.         }
  478.     } else {
  479.         return false;
  480.     }
  481. }
  482.  
  483. function converttonum($convertnum){
  484.     $bits = explode(",",$convertnum); // split input value up to allow checking
  485.  
  486.     $first = strlen($bits[0]); // gets part before first comma (thousands/millions)
  487.     $last = strlen($bits[1]); // gets part after first comma (thousands (or decimals if incorrectly used by user)
  488.  
  489.     if ($last <3){ // checks for comma being used as decimal place
  490.         $convertnum = str_replace(",",".",$convertnum);
  491.     }
  492.     else{ // assume comma is a thousands seperator, so remove it
  493.         $convertnum = str_replace(",","",$convertnum);
  494.     }
  495.  
  496.     return $convertnum; 
  497.  
  498. function get_current_bidder_id($auction_id) {
  499.     $sql = "SELECT bid, bidder, COUNT(bid) AS bid_count
  500.               FROM BPPENNYAUTOBID_bids
  501.               WHERE auction=".$auction_id." GROUP BY bid ORDER BY bid DESC ";
  502.     $result = mysql_query($sql);
  503.     if ($row1=mysql_fetch_array($result)) {
  504.         return $row1['bidder'];
  505.     } else {
  506.         return 0;
  507.     }
  508. }
  509.  
  510. ?>
Jul 10 '10 #9

Dormilich
Expert Mod 5K+
P: 8,639
which is line 167? (in your listing line 167 is empty)
Jul 11 '10 #10

Topbidder
P: 11
hmmm i will have to check im not too sure


here is line 167 showing on my php
Expand|Select|Wrap|Line Numbers
  1.                     if ($w_seat==1) {
  2.                         $balance -= 1;
  3.                         # $update = "UPDATE BPPENNYAUTOBID_users SET balance=".$balance."                                       
  4.                                                                                       WHERE id=".$user_id;
  5.  
  6.                         mysql_query($update);                    }


but here is the whole code
Expand|Select|Wrap|Line Numbers
  1. <?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);
  2. #// #################################################// 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();}
  3. if(!$id) $id = $_REQUEST[id];
  4. if(!$bid) $bid = $_REQUEST[bid];
  5. $auction_type = $_POST['auction_type'];
  6. $type = $_POST['form_type'];
  7. $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();}
  8. # // ###############################    # 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']) . "'";
  9. //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')";//        
  10. //        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);
  11. do_bid($id,$user_id_,$_POST['bid']);
  12. autobidProcessing($id);    // Save current F5 control number for next check    $_SESSION['f5_num1'] = $_POST['f5_num'];}
  13. /** * NOTE: AUCTION AUTOEXTENSION */
  14. $EXTSETTINGS = @mysql_fetch_array(@mysql_query("SELECT * FROM BPPENNYAUTOBID_auctionextension"));
  15. if($EXTSETTINGS['status'] == 'enabled')
  16. {
  17.     $__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));
  18.     if(($__END - $TIME) <= $EXTSETTINGS['timebefore'])
  19.     {
  20.         $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)));
  21.     }
  22.     $query = "UPDATE BPPENNYAUTOBID_auctions set ends='$auctionends' WHERE id=" . intval($id);
  23.     if(!mysql_query($query))
  24.     {
  25.         MySQLError($query);
  26.         exit();
  27.     }
  28. }        // 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
  29. while($check_row = mysql_fetch_array($check_result)){    // Find out if the bid is unique        
  30.     if($check_row['bid_count'] == 1)    {        // If this unique bid is the highest - it is a winner
  31.         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;}
  32. #########################  Next Bid    #########################################################//$query = "select max(bid) AS maxbid, bidder FROM BPPENNYAUTOBID_bids WHERE auction=" . intval($id) . " GROUP BY auction, bidder ORDER BY maxbid DESC";//
  33. //$result_bids = mysql_query($query);//$customincrement = mysql_result($result, 0, "increment");//$max_bid = mysql_result($result_bids, 0, "maxbid");//
  34. ////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 *///
  35. //$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";//
  36. ////echo "<div style='display:none;'>sql:<br>";////echo "$query</div>";//
  37. //$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;
  38. $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;
  39. header("Location: item.php?id=".$id."&history=view#history");
  40. ////include_once ("bid_list.php");//include_once "header.php";//include_once phpa_include("template_bid_result_php.html");//include_once "footer.php";//exit();
  41. function get_HOW_MANY($auction_id)
  42. {
  43.     $how_many = "&nbsp;";
  44.     if(isset($_SESSION["BPPENNYAUTOBID_LOGGED_IN"]))
  45.     {
  46.         $sql = "SELECT asi.offers
  47.                 FROM BPPENNYAUTOBID_auctions_signed asi
  48.                 INNER JOIN BPPENNYAUTOBID_auctions a ON asi.auction_id=a.id
  49.                 WHERE asi.user_id=" . $_SESSION["BPPENNYAUTOBID_LOGGED_IN"] . " AND
  50.                    asi.auction_id=" . $auction_id . " AND a.auction_type>1";
  51.         $res = mysql_query($sql);
  52.         if($res)
  53.         {
  54.             if(mysql_num_rows($res) > 0)
  55.             {
  56.                 $row1 = mysql_fetch_array($res);
  57.                 $how_many = "Your number of offers available for this auction are: " . $row1['offers'];
  58.             }
  59.         }
  60.     }
  61.     return $how_many;
  62. }
  63. //--------------------------------------------------------------------------// 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) {
  64.  
  65.     if (intval($auction_id)>0) {
  66.         $result = mysql_query("SELECT * FROM BPPENNYAUTOBID_auctions WHERE id=" . intval($auction_id));
  67.         $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");
  68.  
  69.         $customincrement = mysql_result($result, 0, "increment");
  70.         $max_bid = mysql_result($result_bids, 0, "maxbid");
  71.         $minimum_bid = mysql_result($result, 0, "minimum_bid");
  72.         if($max_bid == 0) {
  73.             $MAX_BID = $minimum_bid;
  74.             //// Added by Yosi 22 Jul 2009 - consider if auction starts with some value
  75.             $max_bid = $minimum_bid;
  76.         }else
  77.         {
  78.             $MAX_BID = $max_bid;
  79.         }
  80.         /* Get bid increment for current bid and calculate minimum bid */
  81.  
  82.         $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";
  83.  
  84.         //echo "<div style='display:none;'>sql:<br>";
  85.         //echo "$query</div>";
  86.  
  87.         $result_incr = mysql_query($query);
  88.         if(mysql_num_rows($result_incr) != 0)
  89.         {
  90.             $increment = mysql_result($result_incr, 0, "increment");
  91.         }
  92.         if($customincrement > 0)
  93.         {    
  94.             $increment = $customincrement;
  95.         }
  96.  
  97.         if($max_bid == 0 || $atype == 2)
  98.         {
  99.             $next_bid = $minimum_bid;
  100.         }else
  101.         {    
  102.             $next_bid = $max_bid + $increment;
  103.         }
  104.         return $next_bid;
  105.     } else {
  106.         return 0;
  107.     }
  108. }
  109.  
  110. function autobidProcessing($auction_id=0) {
  111.     if (intval($auction_id)>0) {
  112.         //do {
  113.             $sql="SELECT
  114.                     BPPENNYAUTOBID_autobids.id,
  115.                     BPPENNYAUTOBID_autobids.bidder_id,
  116.                     BPPENNYAUTOBID_autobids.remained_bids,
  117.                     BPPENNYAUTOBID_autobids.max_amount,
  118.                     BPPENNYAUTOBID_users.balance
  119.                 FROM BPPENNYAUTOBID_autobids
  120.                 INNER JOIN BPPENNYAUTOBID_users ON BPPENNYAUTOBID_autobids.bidder_id=BPPENNYAUTOBID_users.id
  121.                 WHERE
  122.                     BPPENNYAUTOBID_autobids.auction_id='".$auction_id."'";
  123.             $result=mysql_query($sql);
  124.             //$return_flag=false;
  125.             $bid_flag=false;
  126.             while($row=mysql_fetch_array($result)) {
  127.                 if ($row['remained_bids']>0 && $row['max_amount']>get_next_bid($auction_id)) {
  128.                     if ($row['bidder_id']!=get_current_bidder_id($auction_id)) {
  129.                         if (do_bid($auction_id,$row['bidder_id'],get_next_bid($auction_id))) {
  130.                             mysql_query("UPDATE BPPENNYAUTOBID_autobids SET remained_bids=remained_bids-1 WHERE id='".$row['id']."'");
  131.                             $bid_flag=true;
  132.                         }
  133.                     }
  134.                 }
  135.             }
  136.         //} while ($bid_flag);
  137.     }
  138. }
  139.  
  140.  
  141. function do_bid($auction_id,$user_id,$bid_value) {
  142.     global $NOW;
  143.  
  144.  
  145.     if (intval($auction_id)>0 && intval($user_id)>0 && $bid_value>0) {
  146.  
  147.         $result_b = mysql_query("SELECT id, balance FROM BPPENNYAUTOBID_users WHERE id='" .$user_id. "'");
  148.         $bal_row = mysql_fetch_array($result_b);
  149.         $balance = $bal_row['balance'];
  150.  
  151.         $sql="SELECT ends,bid_value,closed,w_seat FROM BPPENNYAUTOBID_auctions WHERE id='".$auction_id."'";
  152.         $result1=mysql_query($sql);
  153.         $ends = mysql_result($result1, 0, "ends");
  154.         $closed = mysql_result($result1, 0, "closed");
  155.         $w_seat=mysql_result($result1, 0, "w_seat");        
  156.         if ($closed==0) {    
  157.             if (($balance>0 && $w_seat==1)||($w_seat==2)) {
  158.                 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)
  159.                                VALUES('" .$auction_id. ".','." .$user_id. ".','.".converttonum(get_next_bid($auction_id)). ".','." .$NOW. ".').";
  160.  
  161.  
  162.                     mysql_query($insert);
  163.  
  164.  
  165.                     if ($w_seat==1) {
  166.                         $balance -= 1;
  167.                         # $update = "UPDATE BPPENNYAUTOBID_users SET balance=".$balance."                                       
  168.                                                                                       WHERE id=".$user_id;
  169.  
  170.                         mysql_query($update);                    }                    return true;                } else {                    return false;                }
  171.             } else {
  172.                 return false;    
  173.             }
  174.         } else {
  175.             return false;
  176.         }
  177.     } else {
  178.         return false;
  179.     }
  180. }
  181.  
  182. function converttonum($convertnum){
  183.     $bits = explode(",",$convertnum); // split input value up to allow checking
  184.  
  185.     $first = strlen($bits[0]); // gets part before first comma (thousands/millions)
  186.     $last = strlen($bits[1]); // gets part after first comma (thousands (or decimals if incorrectly used by user)
  187.  
  188.     if ($last <3){ // checks for comma being used as decimal place
  189.         $convertnum = str_replace(",",".",$convertnum);
  190.     }
  191.     else{ // assume comma is a thousands seperator, so remove it
  192.         $convertnum = str_replace(",","",$convertnum);
  193.     }
  194.  
  195.     return $convertnum; 
  196.  
  197. function get_current_bidder_id($auction_id) {
  198.     $sql = "SELECT bid, bidder, COUNT(bid) AS bid_count
  199.               FROM BPPENNYAUTOBID_bids
  200.               WHERE auction=".$auction_id." GROUP BY bid ORDER BY bid DESC ";
  201.     $result = mysql_query($sql);
  202.     if ($row1=mysql_fetch_array($result)) {
  203.         return $row1['bidder'];
  204.     } else {
  205.         return 0;
  206.     }
  207. }
  208. ?>
Jul 11 '10 #11

TheServant
Expert 100+
P: 1,168
What is # doing there?
Jul 11 '10 #12

Samishii23
100+
P: 246
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.
Jul 12 '10 #13

Topbidder
P: 11
@ 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
http://www.top-bidder.com
http://www.ibparcadia.info

without all your help i wouldnt been able to get the bugs out many thanks again
Jul 12 '10 #14

Post your reply

Sign in to post your reply or Sign up for a free account.