0
<?php
require_once('mail.inc.php');
$con = mysql_connect("localhost","root","12345");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("billtest",$con);
$today=strtotime(date("Y-m-d"));
$query1="SELECT * FROM ab_transactions_paypal WHERE status=0 AND expiry_date>$today";
$result=mysql_query($query1);
if(mysql_num_rows($result)>0){
$count=mysql_num_rows($result);
for($j=0;$j<$count;$j++){
$row=mysql_fetch_array($result);
$token_id=$row['token_id'];
$account_id=$row['account_id'];
$sku=$row["sku"];
$inv_id=$row['invoice_id'];
$bill_amt=$row['amount'];
$cust_email=$row['cust_email'];
$url="https://ssl.3gsecure.net/api/payment/checktoken.asp?TransactionToken=$token_id";
$httpRequest_OBJ = new httpRequest($url, HTTP_METH_POST);
$result = $httpRequest_OBJ->send();
$mine=$httpRequest_OBJ->getResponseBody();
echo $httpRequest_OBJ->getResponseBody();
$s = explode(";",$mine);
foreach($s as $k){
 $v=explode("=",$k);
  $a[$v[0]]=$v[1];
}
//print_r($a);
echo "<br />";
//echo $a['TransactionStatus'];
echo "<br />";
if(($a['TransactionStatus'])==000){
$q_update = "UPDATE ab_transactions_paypal SET status=1 WHERE invoice_id=$inv_id AND account_id=$account_id AND sku='$sku'";
mysql_query($q_update) ;

$sql = "UPDATE ab_invoice SET billed_amt=$bill_amt,billing_status=1,process_status=1 WHERE id=$inv_id AND account_id=$account_id AND sku='$sku'";
mysql_query($sql) ;
#begin service recharge##
$query9="SELECT * FROM ab_service WHERE  account_id=$account_id AND sku='$sku'";
//echo $skus;
//mysql_query($query);
$result9=mysql_query($query9);
$row9=mysql_fetch_array($result9);
$cycle=$row9['recur_type'];
$curr_balance=$row9['usage_balance'];
$mcf=$row9['mcf'];
$price=$row9['price'];
$amt=$bill_amt;
switch($cycle){
                   //DO STUFF   
                      } 

if($amt<$price){
 //DO STUFF
}
else{
//SOME CODE HERE

if ($account_type=="CORPORATE"){

//do stuff A
}
else{
//do stuff B
}
if($account_type=="CORPORATE"){
//dO stuff C
}
else{
//dO stuff D
}
##initialize sendmails class-by creating an object from it##
$sendmail=new sendmails();
##now send the email##
$html=$message;
$sendmail->authSendEmail($from,$to,$subject, $html) ;

} 
##end service recharge ##                                        
}
else{
echo "Payment For The Specified Client Has not been effected. Please wait...";
}
}}
else{
echo "no client";
}
?>

The above code picks all rows that meet criteria from the database. however,from the list of rows in array, it transacts for only one row i.e does not move next and repeat doing specified stuff until it exhausts the array. how can i overcome this ? can somebody re-write it so that it can loop through all elements doing stuff ?

Edited by mogaka

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by pritaeas
0

$httpRequest_OBJ = new httpRequest($url, HTTP_METH_POST);

Should be:

$httpRequest_OBJ = new HttpRequest($url, HTTP_METH_POST); // Capital 'H'
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.