Avatar billede anddk Praktikant
25. oktober 2008 - 18:16 Der er 9 kommentarer

Dårlig kode, noget bliver ikke udført

Hejsa

Er der en som vil se om det skulle være noget galt med denne kode.
Problemet er at "include ("$cfgTplPath/order_exec.tpl");" ikke bliver udført mere. Det har virket i længe men pluselig bliver denne siden ikke vist. Det er noget jeg har overtaget fra en anden og jeg har ikke så meget styr på php, desværre..

Fornemmer at det ikke er særlig godt kodet...


if ($btnOrderExec || strlen($btnOrderExec_x))
{
    $nCustomerID = $_SESSION['customerid'];
    // Execute the order
    $bExOrder = ExecuteOrder ($nCustomerID);
    if ($bExOrder)
    {
        include ("$cfgTplPath/order_exec.tpl");
        if ($bLogDone)
            $VID = "";
    }
    else 
        echo $cfgErrOrder[2];
}
Avatar billede askilada Nybegynder
25. oktober 2008 - 20:01 #1
if ($btnOrderExec || strlen($btnOrderExec_x))

er det så ikke mere optimalt at tjekke om $btnOrderEcec_x findes?

og hvordan der functionen "ExecuteOrder()" ud ?
Avatar billede anddk Praktikant
25. oktober 2008 - 21:54 #2
Jo, det kunne nok være en god ide.

Det undre mig bare lidt hvorfor det har virket fint i lang tig og pluselig er holdt op. Ingen har ændret i koden.

Funktionen ExecuteOrder() er bare en side hvor der står at ordren er modtaget. Ordre bliver fint modtaget i butikken men siden hvor det står blive bare ikke vist mere og det skulle den kode jo gerne poste.
Avatar billede askilada Nybegynder
25. oktober 2008 - 22:34 #3
Husker du at return true i din ExecuteOrder () ?
Avatar billede anddk Praktikant
26. oktober 2008 - 10:03 #4
Det ser ikke sådan ud, min order_exec.tpl, ser sådan ud:

<table border="0" width="100%" cellpadding=3 cellspacing=0 bordercolor="#000000" align="center">
  <tr>
      <td class="bodytext">
        Din bestilling...
        <table width=100% cellpadding="20" cellspacing="0" border="0">
            <tr>
              <td class="bodytext">
                  <b>...er gennemført.<br><br>
                    Du vil modtage en bekr&aelig;ftelse pr. e-mail nu !.
                    </b>
                  <p align="right">Tak for din bestilling!</p>
              </td>
            </tr>
        </table>
      </td>
  </tr>
</table>
Avatar billede askilada Nybegynder
26. oktober 2008 - 22:09 #5
Men hvad laver du af return i "ExecuteOrder()" ?
Avatar billede anddk Praktikant
27. oktober 2008 - 18:42 #6
Har ikke helt styr på koden, så jeg kager lidt rundt i det. (beklager....)

Her er den:


function ExecuteOrder ($nAdressID, $transact="")
{
    include ("inc/cfg_sql.inc.php");
    include ("inc/cfg_general.inc.php");
    $VID = session_id();
    $cfgFoCuRate = config("euro");
    if ($VID)
    {
        // Add the adress-id to the array
        $saOrder["customer_id"] = $_SESSION['customerid'];
        if (DEBUG) echo "\n<!-- debug: $saOrder[customer_id] -->\n";
        $connectionID = OpenDatabase();
        // Generate Order Number
        $svSQL = "insert into $cfgTabOrderCount (time_stamp) values (now())"; // ok so far
        $result = mysql_query($svSQL,$connectionID);
        $nOrderCount = mysql_insert_id($connectionID);
        $svOrderNumberDate = FormatDateTime (date('Ymdhis'), $cfgOrderPrefix["date"]);
        $saOrder["order_number"] = $cfgOrderPrefix["char"] . $svOrderNumberDate . $nOrderCount;
        // Read the basket
        $svSQL = "select quantity,article_id,tax_rate,price
                  from $cfgTabBasket
                where visit_key='$VID'";
        $result = @mysql_query($svSQL,$connectionID);
     
        if (DEBUG) echo "\n<!-- debug: $svSQL -->\n";
     
        while ($saRow = mysql_fetch_array($result))
        {
            // Add some fields to the array
            $saOrder["quantity"]  = $saRow["quantity"];
            $saOrder["article_id"] = $saRow["article_id"];
            $saOrder["tax_rate"]  = $saRow["tax_rate"];
            $saOrder["price"]      = $saRow["price"];
            // Add article to the order table
            $bOrderOK = AddArticleOrder ($saOrder);
            if (DEBUG) echo "\n<!-- debug: $bOrderOK -->\n";
        }
    }
    if ($bOrderOK)
    {
        $result = GetOrderContentResult ($saOrder["order_number"]);
        while ($saOrderRow = @mysql_fetch_array($result))
        {
            // Create variable names for templates
            $nBasketArticleID = $saOrderRow["article_id"];
            $nQuantity        = $saOrderRow["quantity"];
            $nPrice          = FormatPrice($saOrderRow["price"]);
            $nSumPrice        = FormatPrice($saOrderRow["sum_price"]);
            $nSumTaxPrice2      += $saOrderRow["sum_price"]*(25/100)+$saOrderRow["sum_price"];
            $nTaxRate        = $saOrderRow["tax_rate"];
            $nID              = $saOrderRow["id"];
            $svGroup          = $saOrderRow["category"];
            $svNumber        = $saOrderRow["product_number"];
            $svName          = $saOrderRow["desc_short"];
            $svWeight          += $saOrderRow["weight"]*$nQuantity;
            $svInfo          = strip_tags($saOrderRow["desc_long"]);
            $nFoCuPrice      = FormatPrice($saOrderRow["focu_price"]);
            $nFoCuSumPrice    = FormatPrice($saOrderRow["focu_sum_price"]);
            // Get's the article fields as an array. Can be used as $saArticle[fieldname] in the email.
            $saArticle = GetArticle($saOrderRow["article_id"]);
            // Define the part we wanna use of the email
            $svEmailPart = "loop";
            include ("inc/cfg_mail.inc.php");
            $svMailText .= $cfgMailArticleRow;
        }
        // Order summary
        $saOrderSum = GetOrderSumResult ($saOrder["order_number"]);
        // Shipping costs
        //$saShipCost = GetShippingCosts ($saOrderSum["price"]);
        $saAdress      = GetAdress($nAdressID);
        if($saAdress["order_type"]=="Afhentning")
            $saShipCost="0";
        else
            $saShipCost = GetShippingCosts ($svWeight);
        if($saAdress['order_type']=="Efterkrav")
            $saShipCost3 = $cfgPO;
        else
            $saShipCost3 = "0";

        if($saAdress['order_type']=="Kreditkort")
            $saShipCost4 = "2.00";
        else
            $saShipCost4 = "0";

        if($saAdress['order_type']=="Bankoverforsel")
            $saShipCost2 = 0;
        else
            $saShipCost2 = "0";

        $saShipCost2 = GetShippingCosts2 ($nSumTaxPrice2);
        $nShippingCosts2  = $saShipCost2["price"];

        // Totals
        $saTotalSum = GetTotalSum ($saOrderSum,"");
        // Formatting stuff
        $nSubSumNet              = FormatPrice($saTotalSum["subsum_net"]);
        $nTotalTaxPartNet        = FormatPrice($saTotalSum["taxpart_net"]);
        $nTotalSumNet            = FormatPrice($nSumTaxPrice2+$saShipCost+$nShippingCosts2+$saShipCost3+$saShipCost4);
        $nTotalSumGross          = FormatPrice($saTotalSum["totalsum_gross"]);
        $nTotalTaxPartGross      = FormatPrice($saTotalSum["taxpart_gross"]);
        $nFoCuSubSumNet          = FormatPrice($saTotalSum["focu_subsum_net"]);
        $nFoCuTotalTaxPartNet    = FormatPrice($saTotalSum["focu_taxpart_net"]);
        $nFoCuTotalSumNet        = FormatPrice(($nSumTaxPrice2+$saShipCost+$nShippingCosts2+$saShipCost3+$saShipCost4)/$cfgFoCuRate);
        $nFoCuTotalSumGross      = FormatPrice($saTotalSum["focu_totalsum_gross"]);
        $nFoCuTotalTaxPartGross  = FormatPrice($saTotalSum["focu_taxpart_gross"]);
        // Formating shipping costs
        $nShippingCosts          = FormatPrice($saShipCost["price"]);
        $nShippingCostsLimit    = FormatPrice($saShipCost["limit"]);
        $nShipCostsTaxGross      = FormatPrice($saShipCost["taxgross"]);
        $nShipCostsTaxNet        = FormatPrice($saShipCost["taxnet"]);
        $nFoCuShippingCosts      = FormatPrice($saShipCost["focu_price"]);
        $nFoCuShippingCostsLimit = FormatPrice($saShipCost["focu_limit"]);
        $nFoCuShipCostsTaxGross  = FormatPrice($saShipCost["focu_taxgross"]);
        $nFoCuShipCostsTaxNet    = FormatPrice($saShipCost["focu_taxnet"]);
       
        // Declare the vars for the email template
        // Possible table fields
        $svSalutation    = $saAdress["salutation"];
        $svCompany        = $saAdress["company"];
        $svFirstname    = $saAdress["firstname"];
        $svSurname        = $saAdress["surname"];
        $svStreet        = $saAdress["street"];
        $svZipCode        = $saAdress["zipcode"];
        $svTown            = $saAdress["city"];
        $svPayment        = $saAdress["order_type"];
        $svEmail        = $saAdress["email"];
        $svMessage        = $saAdress["message"];
        $svOrderNumber    = $saOrder["order_number"];
        $svCountry        = $saAdress["country"];
        $svPhone        = $saAdress["phone"];
        $svFax            = $saAdress["fax"];
        $svEmail        = $saAdress["email"];
        if($transact!="")
            $transact = $transact;
        // Shop Owner Email
        $cfgEmailShopOwner = config("shop_owner_email");
        // subject of the email
        $cfgMailSubject = config("email_subject")." Nr.: $svOrderNumber";
        // Mail footer
        $cfgMailFooter = config("mail_footer");
        // Show mail onscreen
        $cfgMailSend = config("mail_send");
        //$cfgMailSend = 0;
        // Define the part we want use of the email
        $svEmailPart = "start";
        include ("inc/cfg_mail.inc.php");
        // Compose email to the customer and to the shop owner
        $svMailText = $cfgMailStart . $svMailText . $cfgMailEnd;
        if ($cfgMailSend)
        {
            // Email to customer
            mail($svEmail, $cfgMailSubject, $svMailText, "From: $cfgEmailShopOwner");
            // Email to shop owner
            mail($cfgEmailShopOwner, $cfgMailSubject, $svMailText, "From: $cfgEmailShopOwner");
        }
        else
        {
            echo "<code>
            \nFrom: $cfgEmailShopOwner<br>
            \nTo: $svEmail,$cfgEmailShopOwner<br>
            \nSubject: $cfgMailSubject<br>
            " . nl2br($svMailText)
            . "</code>";
        }
        DeleteBasket();
        session_clear();
    }
    return $bOrderOK;
}
Avatar billede askilada Nybegynder
27. oktober 2008 - 19:43 #7
Prøv med den her kode en gang :)
--------------------------------

function ExecuteOrder ($nAdressID, $transact="")
{
    include ("inc/cfg_sql.inc.php");
    include ("inc/cfg_general.inc.php");
    $VID = session_id();
    $cfgFoCuRate = config("euro");
    if ($VID)
    {
        // Add the adress-id to the array
        $saOrder["customer_id"] = $_SESSION['customerid'];
        if (DEBUG) echo "\n<!-- debug: $saOrder[customer_id] -->\n";
        $connectionID = OpenDatabase();
        // Generate Order Number
        $svSQL = "insert into $cfgTabOrderCount (time_stamp) values (now())"; // ok so far
        $result = mysql_query($svSQL,$connectionID);
        $nOrderCount = mysql_insert_id($connectionID);
        $svOrderNumberDate = FormatDateTime (date('Ymdhis'), $cfgOrderPrefix["date"]);
        $saOrder["order_number"] = $cfgOrderPrefix["char"] . $svOrderNumberDate . $nOrderCount;
        // Read the basket
        $svSQL = "select quantity,article_id,tax_rate,price
                  from $cfgTabBasket
                where visit_key='$VID'";
        $result = @mysql_query($svSQL,$connectionID);
   
        if (DEBUG) echo "\n<!-- debug: $svSQL -->\n";
   
        while ($saRow = mysql_fetch_array($result))
        {
            // Add some fields to the array
            $saOrder["quantity"]  = $saRow["quantity"];
            $saOrder["article_id"] = $saRow["article_id"];
            $saOrder["tax_rate"]  = $saRow["tax_rate"];
            $saOrder["price"]      = $saRow["price"];
            // Add article to the order table
            $bOrderOK = AddArticleOrder ($saOrder);
            if (DEBUG) echo "\n<!-- debug: $bOrderOK -->\n";
        }
    }
    if ($bOrderOK)
    {
        $result = GetOrderContentResult ($saOrder["order_number"]);
        while ($saOrderRow = @mysql_fetch_array($result))
        {
            // Create variable names for templates
            $nBasketArticleID = $saOrderRow["article_id"];
            $nQuantity        = $saOrderRow["quantity"];
            $nPrice          = FormatPrice($saOrderRow["price"]);
            $nSumPrice        = FormatPrice($saOrderRow["sum_price"]);
            $nSumTaxPrice2      += $saOrderRow["sum_price"]*(25/100)+$saOrderRow["sum_price"];
            $nTaxRate        = $saOrderRow["tax_rate"];
            $nID              = $saOrderRow["id"];
            $svGroup          = $saOrderRow["category"];
            $svNumber        = $saOrderRow["product_number"];
            $svName          = $saOrderRow["desc_short"];
            $svWeight          += $saOrderRow["weight"]*$nQuantity;
            $svInfo          = strip_tags($saOrderRow["desc_long"]);
            $nFoCuPrice      = FormatPrice($saOrderRow["focu_price"]);
            $nFoCuSumPrice    = FormatPrice($saOrderRow["focu_sum_price"]);
            // Get's the article fields as an array. Can be used as $saArticle[fieldname] in the email.
            $saArticle = GetArticle($saOrderRow["article_id"]);
            // Define the part we wanna use of the email
            $svEmailPart = "loop";
            include ("inc/cfg_mail.inc.php");
            $svMailText .= $cfgMailArticleRow;
        }
        // Order summary
        $saOrderSum = GetOrderSumResult ($saOrder["order_number"]);
        // Shipping costs
        //$saShipCost = GetShippingCosts ($saOrderSum["price"]);
        $saAdress      = GetAdress($nAdressID);
        if($saAdress["order_type"]=="Afhentning")
            $saShipCost="0";
        else
            $saShipCost = GetShippingCosts ($svWeight);
        if($saAdress['order_type']=="Efterkrav")
            $saShipCost3 = $cfgPO;
        else
            $saShipCost3 = "0";

        if($saAdress['order_type']=="Kreditkort")
            $saShipCost4 = "2.00";
        else
            $saShipCost4 = "0";

        if($saAdress['order_type']=="Bankoverforsel")
            $saShipCost2 = 0;
        else
            $saShipCost2 = "0";

        $saShipCost2 = GetShippingCosts2 ($nSumTaxPrice2);
        $nShippingCosts2  = $saShipCost2["price"];

        // Totals
        $saTotalSum = GetTotalSum ($saOrderSum,"");
        // Formatting stuff
        $nSubSumNet              = FormatPrice($saTotalSum["subsum_net"]);
        $nTotalTaxPartNet        = FormatPrice($saTotalSum["taxpart_net"]);
        $nTotalSumNet            = FormatPrice($nSumTaxPrice2+$saShipCost+$nShippingCosts2+$saShipCost3+$saShipCost4);
        $nTotalSumGross          = FormatPrice($saTotalSum["totalsum_gross"]);
        $nTotalTaxPartGross      = FormatPrice($saTotalSum["taxpart_gross"]);
        $nFoCuSubSumNet          = FormatPrice($saTotalSum["focu_subsum_net"]);
        $nFoCuTotalTaxPartNet    = FormatPrice($saTotalSum["focu_taxpart_net"]);
        $nFoCuTotalSumNet        = FormatPrice(($nSumTaxPrice2+$saShipCost+$nShippingCosts2+$saShipCost3+$saShipCost4)/$cfgFoCuRate);
        $nFoCuTotalSumGross      = FormatPrice($saTotalSum["focu_totalsum_gross"]);
        $nFoCuTotalTaxPartGross  = FormatPrice($saTotalSum["focu_taxpart_gross"]);
        // Formating shipping costs
        $nShippingCosts          = FormatPrice($saShipCost["price"]);
        $nShippingCostsLimit    = FormatPrice($saShipCost["limit"]);
        $nShipCostsTaxGross      = FormatPrice($saShipCost["taxgross"]);
        $nShipCostsTaxNet        = FormatPrice($saShipCost["taxnet"]);
        $nFoCuShippingCosts      = FormatPrice($saShipCost["focu_price"]);
        $nFoCuShippingCostsLimit = FormatPrice($saShipCost["focu_limit"]);
        $nFoCuShipCostsTaxGross  = FormatPrice($saShipCost["focu_taxgross"]);
        $nFoCuShipCostsTaxNet    = FormatPrice($saShipCost["focu_taxnet"]);
     
        // Declare the vars for the email template
        // Possible table fields
        $svSalutation    = $saAdress["salutation"];
        $svCompany        = $saAdress["company"];
        $svFirstname    = $saAdress["firstname"];
        $svSurname        = $saAdress["surname"];
        $svStreet        = $saAdress["street"];
        $svZipCode        = $saAdress["zipcode"];
        $svTown            = $saAdress["city"];
        $svPayment        = $saAdress["order_type"];
        $svEmail        = $saAdress["email"];
        $svMessage        = $saAdress["message"];
        $svOrderNumber    = $saOrder["order_number"];
        $svCountry        = $saAdress["country"];
        $svPhone        = $saAdress["phone"];
        $svFax            = $saAdress["fax"];
        $svEmail        = $saAdress["email"];
        if($transact!="")
            $transact = $transact;
        // Shop Owner Email
        $cfgEmailShopOwner = config("shop_owner_email");
        // subject of the email
        $cfgMailSubject = config("email_subject")." Nr.: $svOrderNumber";
        // Mail footer
        $cfgMailFooter = config("mail_footer");
        // Show mail onscreen
        $cfgMailSend = config("mail_send");
        //$cfgMailSend = 0;
        // Define the part we want use of the email
        $svEmailPart = "start";
        include ("inc/cfg_mail.inc.php");
        // Compose email to the customer and to the shop owner
        $svMailText = $cfgMailStart . $svMailText . $cfgMailEnd;
        if ($cfgMailSend)
        {
            // Email to customer
            mail($svEmail, $cfgMailSubject, $svMailText, "From: $cfgEmailShopOwner");
            // Email to shop owner
            mail($cfgEmailShopOwner, $cfgMailSubject, $svMailText, "From: $cfgEmailShopOwner");
        }
        else
        {
            echo "<code>
            \nFrom: $cfgEmailShopOwner<br>
            \nTo: $svEmail,$cfgEmailShopOwner<br>
            \nSubject: $cfgMailSubject<br>
            " . nl2br($svMailText)
            . "</code>";
        }
        DeleteBasket();
        session_clear();
        return $bOrderOK;
    }
    else
    {
        return false;
    }
   
}
Avatar billede anddk Praktikant
29. oktober 2008 - 18:04 #8
Det gjore desvære ikke nogen større forskel. Jeg fik mail men ikke vist afslutningssiden til sidst.

Hvordan hulen fejlsøger man på sådan et problem ?
Avatar billede anddk Praktikant
06. november 2008 - 19:39 #9
Slet ikke flere idere ?

Jeg kan bare ikke få det til at fungere, det er ved at blive et stort problem for mig. :-(
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester