-1

約 300 または 400 の要素を持つ配列があります。foreach次のように、ループを使用してすべての配列要素を処理しています。

$cnt=0;
foreach($resIds as $resId)
{
  $cnt++;
  //my queries and other code 

} 

私の問題は、上記のコードが内部サーバー エラーを引き起こすことです。

ループに 1 つの条件を入れると、次のように最初の 160 ループで正常に機能します。

$cnt=0;
    foreach($resIds as $resId)
    {
      $cnt++;
      if($cnt<=160)
      {
        //my queries and other code 
      }

    } 

$cnt変数を 161に設定すると、 Internal Server Errorというエラーが発生します。

誰でもこれで私を助けることができますか?

ここにコードがあります

foreach($resIds as $resId)
 {

$cnt++;
if($cnt<=160)
{
    $transRes = $conn->query('select * from bb_users where id = '.$resId.' and deleted=0');
    while($trans = $transRes->fetch())
    {
    $user = $cartObj->getUserInfo($trans['Session_Id']);

$cartRes = $conn->query('select * from bb_cart where Session_Id = "'.$user['Session_Id'].'" and deleted=0');
$cartdetail = '';
$finaltotal = '';
$productregisterRes = $conn->query("Select * from product_register where OrderId = '".$user['OrderId']."'")->fetch();   

while($cart = $cartRes->fetch())
{
    $ProductId = $cart['ProductId'];
    $ProductName = $cart['ProductName'];
    if($cart['Color']!="")
    {
        $freeproductname = stripslashes($productregisterRes['FREEProductName']);            
        $freeproductname = str_replace(",Lady Gaga featuring (Born This Way & Bad Romance)", "", $freeproductname);
        $ProductColor = '['.$cart['Color'].']';
    }
    else
    {
        $freeproductname ="";
        $ProductColor ="";
    }
    $ProductQty = $cart['ProductQty'];
    $ProductPrice = $cartObj->getpriceformat($cart['ProductPrice']);                
    $Discount = $cartObj->getpriceformat($cart['Discount']);        
    $TotalPrice = $cartObj->getpriceformat($cart['TotalPrice']);
    $finaltotal += $cart['TotalPrice'];

    $cartdetail .='<tr>
        <td align="left" width="40%">'.stripdata($ProductName).'<br/><I>'.$freeproductname.'<br/>'.$ProductColor.'</I></td>
        <td align="center" width="15%">$'.$ProductPrice.'</td>

        <td align="center" width="15%">'.$ProductQty.'</td>
        <td align="center" width="15%">$'.$Discount.'</td>
        <td align="right" width="15%" style="padding-right:45px">$'.$TotalPrice.'</td>
      </tr>';
}
$VoucherCode=$crypt->decrypt($user['mpcode']);
$State = getStateName($user['State']);
$Country = getCountryName($user['Country']);

$billingname = stripdata($user['FirstName']).' '.stripdata($user['LastName']);
$billingaddress = stripdata($user['Address1']).'<br>'.stripdata($user['City']).', '.$State.' '.stripdata($user['Zip']).'<br>'.$Country;

$ShippingState = getStateName($user['ShippingState']);
$ShippingCountry = getCountryName($user['ShippingCountry']);

$shippingname = stripdata($user['ShippingFirstName']).' '.stripdata($user['ShippingLastName']);
$shippingaddress = stripdata($user['ShippingAddress1']).'<br>'.stripdata($user['ShippingCity']).', '.$ShippingState.' '.stripdata($user['ShippingZip']).'<br>'.$ShippingCountry;

$email = $user['Email'];
$phone = $user['Phone'];
$DateTime = getDateTime($user['DateTime']);
$afterdiscount = $cartObj->getpriceformat($finaltotal) - ($cartObj->getpriceformat($user['mpcode_discount']) + $cartObj->getpriceformat($user['misc_discount']));   
$misc_discount = $cartObj->getpriceformat($user['misc_discount']);

} }

4

1 に答える 1