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

Recommended Answers

All 7 Replies

1. what is your question now.
2. Where is the code for the php file

I hope you will read this and follow instructions

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               //

?>

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

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++;
}

Ok, so what is the question now, buttler code not working or how to run after one minute?

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.