Jump to content


Photo

another header error


  • Please log in to reply
12 replies to this topic

#1 digitalgod

digitalgod
  • Members
  • PipPipPip
  • Advanced Member
  • 374 posts

Posted 07 October 2006 - 05:15 PM

hey guys,

I keep getting this header error

Warning: Cannot modify header information - headers already sent by (output started at /cart/plugins/szukanie/szukanie.php:156) in /cart/actions_client/orders.php on line 50

line 50 in orders.php has a header redirect and session_start is at the very begining of the file

so I'm guessing that the problem is from szukanie.php but I can't seem to see what's causing the error...

here's the content of szukanie.php

<?php

if( !function_exists( 'listProductsSearch' ) ){
  /**
  * List products and return content
  * @return string
  * @param string $sFile
  * @param string $sOption
  * @param mixed  $mValue
  * @param int    $iList
  */
  function listProductsSearch( $sFile = 'products_list.tpl', $sOption = 'list', $mValue = null, $iList = null ){

    if( !isset( $_GET['iPage'] ) || !is_numeric( $_GET['iPage'] ) || $_GET['iPage'] < 1 ) $_GET['iPage'] = 1;
    $iStatus = throwStatus( );
    if( !isset( $iList ) )
     {
     if( $iStatus == 1 ) $iList = PRODUCTS_LIST;
     else $iList = ADMIN_LIST;
     }
    if( $sOption == 'search' ){
      if (isset($mValue[1])) $aData = dbListProductsSearchExtended ( $iStatus, array(trim( $mValue[0] ), $mValue[1], $mValue[2], $mValue[3]), $iList );
      if (isset($mValue[1])) $sPage = $_GET['p'].'&amp;sSearchWord='.$_GET['sSearchWord'].'&Category='.$mValue[1].'&fPriceFrom='.$mValue[2].'&fPriceTo='.$mValue[3];
    }

    if( isset( $aData ) && is_array( $aData ) )
      $content = throwProductsData( $sFile, $aData, $sPage, $iList );
    else
      $content = $_GET['tpl']->tbHtml( $sFile, 'NOT_FOUND' );

    return $content;
  } // end function listProductsSearch
}

function show_categories ($iStatus)
   {
   $aFile =  file( DB_CATEGORIES );
   $iCount = count( $aFile );
   $kategorie =  null;
   for( $i = 1; $i < $iCount; $i++ )
    {
    $aExp = explode( '$', $aFile[$i]);
    if( $aExp[3] >= $iStatus )
     {
     $kategorie[$aExp[0]] = $aExp[1];
     if( is_numeric( $aExp[2] ) && $aExp[2] > 0 ) {$kategorie[$aExp[0]] = $kategorie[$aExp[2]].' '.$kategorie[$aExp[0]]; }
     }
    }
   return $kategorie;
   }

function show_products_ex ()
   {
   $aFile =  file(DB_PRODUCTS_EXT);
   $iCount = count( $aFile );
   $produkty_ex =  null;
   for( $i = 1; $i < $iCount; $i++ )
    {
    $aExp = explode( '$', $aFile[$i]);
    if (isset($aExp[1])) {$produkty_ex[$aExp[0]] = $aExp[1];}
    if (!isset($aExp[1])) {$produkty_ex[$aExp[0]] = "";}
    }
   return $produkty_ex;
   }


function show_products_categories ()
   {
   $aFile =  file(DB_PRODUCTS_CATEGORIES);
   $iCount = count( $aFile );
   $produkty_kategorie =  null;
   for( $i = 1; $i < $iCount; $i++ )
    {
    $aExp = explode( '$', $aFile[$i]);
    $produkty_kategorie[$aExp[1]] = $aExp[0];
    }
   return $produkty_kategorie;
   }


function show_prices_promo ()
   {
   $aFile =  file(DB_PRODUCT_ATTRIBUTES);
   $iCount = count( $aFile );
   $produkty_ceny_promo =  null;
   for( $i = 1; $i < $iCount; $i++ )
    {
    $aExp = explode( '$', $aFile[$i]);
    $produkty_ceny_promo[$aExp[0]] = $aExp[2];
    }
   return $produkty_ceny_promo;
   }


if( !function_exists( 'dbListProductsSearchExtended' ) ){
  /**
  * Return array of products list, search by word
  * @return array
  * @param int    $iStatus
  * @param string $sWord
  * @param int    $iList
  */
  function dbListProductsSearchExtended( $iStatus, $sWord, $iList ){
    global $oFF;
    $aCategories = dbThrowProductsCategories( );
    $kategorie = show_categories (0);
    $produkty_ex = show_products_ex ();
    $produkty_kategorie = show_products_categories ();
    $produkty_ceny_promo = show_prices_promo ();
    return $oFF->throwFileArrayFunctionPages( DB_PRODUCTS, null, $_GET['iPage'], $iList, 'dbListProductsSearchCheckExtended', Array( $iStatus, $aCategories, $sWord[0], $kategorie, $produkty_ex, $produkty_kategorie, $sWord[1], $produkty_ceny_promo, $sWord[2], $sWord[3]) );
  } // end function dbListProductsSearchExtended
}



if( !function_exists( 'dbListProductsSearchCheckExtended' ) ){
  /**
  * Checking data of products
  * @return bool
  * @param array  $aData
  * @param array  $aCheck
  */
  function dbListProductsSearchCheckExtended( $aData, $aCheck ){
  $fPrice = $aData[2];
  if (isset($aCheck[7][$aData[0]]) && is_numeric($aCheck[7][$aData[0]])) $fPrice = $aCheck[7][$aData[0]];
  if (isset($aCheck[8]) && is_numeric($aCheck[8])) {$fPriceFrom = $aCheck[8];} else {$fPriceFrom = '0';}
  if (isset($aCheck[9]) && is_numeric($aCheck[9])) {$fPriceTo = $aCheck[9];} else {$fPriceTo = '';}
  if( is_array( $aData ) &&  isset( $aCheck[1][$aData[0]] ) && $aData[4] >= $aCheck[0] )
      {
      if (($aCheck[2] == '') || ($aCheck[2] != '' && stristr( implode( ' ', $aData ).' '.$aCheck[3][$aCheck[1][$aData[0]][0]].' '.$aCheck[4][$aData[0]], $aCheck[2] )))
       {
       if (($aCheck[6] == '') || (($aCheck[6] != '') && ($aCheck[5][$aData[0]] == $aCheck[6]))) 
        {
        if ((($fPriceTo == '') || (($fPriceTo != '') && ($fPrice <= $fPriceTo))) && ($fPrice >= $fPriceFrom)) 
         {
         return true;
         }
        else return null;
        }
       else return null;
       }
      else return null;
      }
    else
      return null;
  } // end function dbListProductsSearchCheckExtended
}


function ShowSearchExtendedForm ( $sFile = 'extended_search.tpl' )
 {
 global $tpl;
 return $tpl->tbHtml( $sFile, 'EXTENDED_SEARCH_FORM' );
 } 

?>


#2 marcus

marcus
  • Members
  • PipPipPip
  • Advanced Member
  • 1,842 posts
  • LocationRochester, NY

Posted 07 October 2006 - 05:17 PM

     if( is_numeric( $aExp[2] ) && $aExp[2] > 0 ) {$kategorie[$aExp[0]] = $kategorie[$aExp[2]].' '.$kategorie[$aExp[0]]; }
     }
    }
   return $kategorie;
   } //< line 50

i get no errors

#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 07 October 2006 - 05:18 PM

What is line 156 of szukanie.php? The error is telling you where the output started.

Ken

#4 marcus

marcus
  • Members
  • PipPipPip
  • Advanced Member
  • 1,842 posts
  • LocationRochester, NY

Posted 07 October 2006 - 05:18 PM

and line 156 is ?>

#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 07 October 2006 - 05:20 PM



i only use this method if it is so needed other wise post the lines that are wrong or i think it's in another page.php.

put ob_start(); at the top of the page

and at the bottom ob_end_flash();
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#6 digitalgod

digitalgod
  • Members
  • PipPipPip
  • Advanced Member
  • 374 posts

Posted 07 October 2006 - 05:27 PM

@kenrbnsn : line 156 is ?>

@redarror : didn't work still get the same error... did you mean to put it in orders.php or szukanie.php?

edit

tried putting that in orders.php as well but got the error except now it's pointing to line 155 which is ob_end_flush();

#7 marcus

marcus
  • Members
  • PipPipPip
  • Advanced Member
  • 1,842 posts
  • LocationRochester, NY

Posted 07 October 2006 - 05:29 PM

show us orders.php

#8 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 07 October 2006 - 05:31 PM

your problam is with a page that you have not posted yet so post the page with the problam and yes you can use the provided php syntex on any page ok.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#9 digitalgod

digitalgod
  • Members
  • PipPipPip
  • Advanced Member
  • 374 posts

Posted 07 October 2006 - 05:32 PM

orders.php

<?php
session_start( );

if( !isset( $_SESSION['iCustomer'] ) )
  $_SESSION['iCustomer'] = time( ).rand( 100, 999 );

require_once DIR_CORE.'couriers-'.$config['db_type'].'.php';
require_once DIR_CORE.'couriers.php';

require_once DIR_CORE.'orders-'.$config['db_type'].'.php';
require_once DIR_CORE.'orders.php';

require_once DIR_CORE.'products-'.$config['db_type'].'.php';
require_once DIR_CORE.'products.php';

if( $a == 'Basket' ){
  if( isset( $sOption ) ){
    if( isset( $_SESSION['iOrderSession'] ) )
      $iOrder = $_SESSION['iOrderSession'];
    else{
      $_SESSION['iOrderSession'] = $iOrder = throwOrderIdTemp( $_SESSION['iCustomer'], 'add' );
    }

    if( $sOption == 'add' ){
      if( isset( $iProduct ) && is_numeric( $iProduct ) && isset( $iQuantity ) && is_numeric( $iQuantity ) && $iQuantity >= 1 && $iQuantity < 1000 ){
        addOrderProduct( $iProduct, $iQuantity, $iOrder );
      }
      // added for not showing basket after clicking add to basket
      echo "<script type='text/javascript' language='javascript'>
      history.go(-1);
      </script>";
      exit;
      // end
      // original code
      header( 'Location: '.$_SERVER['PHP_SELF'].'?p=ordersBasket' );
      exit;
      // original code
    }
    elseif( $sOption == 'del' ){
      if( isset( $iElement ) && is_numeric( $iElement ) )
        delOrderElement( $iOrder, $iElement );
    }
    elseif( $sOption == 'save' ){
      if( isset( $_POST['aElements'] ) && is_array( $_POST['aElements'] ) ){
        saveOrderProducts( $_POST );
      }

      if( isset( $_POST['sSave'] ) ){
        header( 'Location: '.$_SERVER['PHP_SELF'].'?p=ordersDelivery' );
        exit;
      }
    }
  }
  else{
    if( isset( $_SESSION['iOrderSession'] ) )
      $iOrder = $_SESSION['iOrderSession'];
  }
  if( isset( $iOrder ) && is_numeric( $iOrder ) )
    $content .= listBasket( $iOrder );
  else
    $content .= $tpl->tbHtml( 'orders_basket.tpl', 'NOT_FOUND' );
}
elseif( $a == 'Delivery' ){
  if( isset( $_SESSION['iOrderSession'] ) )
    $iOrder = $_SESSION['iOrderSession'];

  if( isset( $iOrder ) && is_numeric( $iOrder ) ){
    if( isset( $_POST['sOption'] ) && $_POST['sOption'] == 'send' ){
      if( checkOrderFields( $_POST ) === true && checkOrderProducts( $iOrder ) === true ){
        saveOrder( $iOrder, $_POST );
		//--------- Start PayPal Code
		$aData = throwOrder( $iOrder );
		listBasket( $iOrder);
		$aData['fSummary'] = sprintf( '%01.2f', $aData['fCourierPrice'] + $aList['fSummary'] );
		if( $aData['fCourierPrice'] > 0 ){
		$content .= $tpl->tbHtml( 'messages.tpl', 'ORDER_PAYPAL' );
		}
		else
		//-------- End PayPal Code
        $content .= $tpl->tbHtml( 'messages.tpl', 'ORDER_SAVED' );
        unset( $_SESSION['iOrderSession'] );
      }
      else
        $content .= $tpl->tbHtml( 'messages.tpl', 'FORM_ERROR' );
    }
    else{
      if( checkOrderProducts( $iOrder ) === true ){
        $sCourierSelect = listCouriers( 'couriers_select.tpl' );
        $content .= $tpl->tbHtml( 'orders_delivery.tpl', 'FORM' );
        $content .= listBasket( $iOrder, 'orders_delivery.tpl' );
        $content .= $tpl->tbHtml( 'orders_delivery.tpl', 'COURIER' );
      }
      else
        $content .= $tpl->tbHtml( 'messages.tpl', 'NOT_EXISTS' );
    }
  }
  else
    $content .= $tpl->tbHtml( 'orders_basket.tpl', 'NOT_FOUND' );
}
elseif( $a == 'Print' && isset( $iOrder ) && is_numeric( $iOrder ) ){
  $aData = throwOrder( $iOrder );
  if( isset( $aData ) && is_array( $aData ) && $aData['iClient'] == $_SESSION['iCustomer'] && $aData['iStatus'] > 0 ){

    $aData['sComment']  = ereg_replace( '\|n\|', "<br />" , $aData['sComment'] );

    $content .= $tpl->tbHtml( 'orders_print.tpl', 'SHOW' );
    if( checkOrderProducts( $iOrder ) === true ){
      $content .= listBasket( $iOrder, 'orders_print.tpl' );
      $aData['fSummary'] = tPrice( $aData['fCourierPrice'] + $aList['fSummary'] );
      $content .= $tpl->tbHtml( 'orders_print.tpl', 'COURIER' );
    }
  }
  else{
    $content .= $tpl->tbHtml( 'messages.tpl', 'ERROR' );
  }
}
else
  $content .= $tpl->tbHtml( 'messages.tpl', 'ERROR' );
?>


#10 marcus

marcus
  • Members
  • PipPipPip
  • Advanced Member
  • 1,842 posts
  • LocationRochester, NY

Posted 07 October 2006 - 05:33 PM

dreamweaver picks up no errors

      if( isset( $_POST['sSave'] ) ){
        header( 'Location: '.$_SERVER['PHP_SELF'].'?p=ordersDelivery' );
        exit; //<line 50


#11 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 07 October 2006 - 05:34 PM

try this at the end of the code or you can use @ob_end_flash();

while (ob_get_level() > 0) {
  ob_end_flush();
}
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#12 digitalgod

digitalgod
  • Members
  • PipPipPip
  • Advanced Member
  • 374 posts

Posted 07 October 2006 - 05:44 PM

still getting the same error :S

@mgallforever: dreamweaver shouldn't pick up any errors, it's a header problem not a syntax error

#13 digitalgod

digitalgod
  • Members
  • PipPipPip
  • Advanced Member
  • 374 posts

Posted 07 October 2006 - 06:00 PM

well oddly enough the problem was from another file that used headers, I added ob_start() to it and now everything works perfectly.

thanks for your help guys




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users