0

Its urgent
I have a auction script
In that bid butler is not working
I have code butler.php but depends on cron
I dnt know how to run cron to run butler.php each 1 min.
Plz help me

2
Contributors
7
Replies
8
Views
6 Years
Discussion Span
Last Post by Stefano Mtangoo
0

thanx evstevemd
for such quick reply
I m attaching my butler.php code
I hope it wil make my que clear

<?php

include("include/db.inc.php"); 

include("include/functions.php"); 

   $db1=new db;

   $db1->open();

   mysql_query("SET NAMES 'utf8'"); 		





set_time_limit (0);



$q=1;

while($q < 61)

{

bidbutler();
//echo $q;
sleep(1);

$q++;

}



function bidbutler()

{

$r=rand(4,11);

//$r=rand(2,3);



 $res=mysql_query("SELECT distinct(b.uid),b.id, t.pid 

FROM t123go_product t

INNER JOIN t123go_butler b ON b.pid = t.pid

AND bider_id != b.uid

WHERE  max_price > bid_price

AND min_price < bid_price

AND TIME_TO_SEC( TIMEDIFF( end_time,NOW() ) ) <= $r and end_time > NOW() and no_bids > 0 order by rand()");

if(!$res){
die(mysql_error());	
}
 

 if(mysql_num_rows($res)>0)

 {

    $x=1;

    while($prec=mysql_fetch_array($res))

	{	
	$chk=mysql_query("select no_bids from user where id='".$prec['uid']."'");
	if(!$chk){
	die(mysql_error());	
	}
	$bidrec=mysql_fetch_array($chk);

	$numbids=$bidrec[0];

	

	if($numbids > 0)

	{

	
echo $numbids;
	 	$rec=mysql_fetch_array(mysql_query("select date_format(end_time,'%Y-%m-%d %H:%i:%s')as et ,bid_price,type1,total_bids from t123go_product where pid='$prec[pid]'"));

	

		$bid_incr=get_increment($rec['type1'],$rec['total_bids']);	  

	

	 	$price=$rec['bid_price'] + $bid_incr[0];	

	

		$entry1= mysql_query("insert into t123go_bid set uid='$prec[uid]',pid='$prec[pid]',product_price='$price',bid_time=now(),type='bidbutler'");
		if(!$entry1){
		die(mysql_error());	
		}
		 

		$entry2= mysql_query("update user set no_bids=no_bids-1 where id='".$prec[uid]."'");
		if(!$entry2){
		die(mysql_error());	
		}
		 

		 $entry3= mysql_query("update t123go_butler set no_bids=no_bids-1 where uid='".$prec[uid]."' and pid='".$prec[pid]."'");	 
		if(!$entry3){
		die(mysql_error());	
		}
	 

		if($x==1)

		{

		 mysql_query("update t123go_product set end_time=DATE_ADD('$rec[et]', INTERVAL $bid_incr[1] SECOND),

		   bid_price='$price',bider_id='$prec[uid]',total_bids=total_bids+1,bid_type='bidbutler' where pid='$prec[pid]'")or die(mysql_error());

		}

		else

		{

		mysql_query("update t123go_product set bid_price='$price',bider_id='$prec[uid]',total_bids=total_bids+1,

		bid_type='bidbutler' where pid='$prec[pid]'")or die(mysql_error());

		}

	}	

	

	

	$x++;  

	}  

 } 





}




//   * * * * * localhost/mybiddoo/beta_auction/butler.php               //

?>

Edited by peter_budo: Keep It clear - Do wrap your programming code blocks within [code] ... [/code] tags

0

Let me help this way, Just state what is the issue in concise words, post error message if any and *relevant* code (not whole code). Also use code tags to wrap your code i.e code=PHP and /code wrapped in square brackets

And about running it on every give time/date, that is cron's work. I think each Linux have that and window has scheduler. So it depends on OS/distribution

0

Sorry for your inconvienience
Actually I am giving users a functionality to set their bid butler on any auction which in their absence will bid automatically in last 4 seconds.
For that I need to run my file butler.php in every 1 minute so that database is updated.
I am including my code

set_time_limit (0);
$q=1;
while($q < 61)
{
bidbutler();
sleep(1);
$q++;
}
0

I have both questions
I just waat to run my butler anyhow
Can you plz help me out

0

Let us start from scratch (I'm not auction maverick so be descriptive), can you outline how that script is supposed to work (No code for now)? I mean Just something like:
1. User Fills the form
2. User submits and it get into database
...........................

Because I don't know how Auction Bid butler works

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.