Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2010
    Posts
    136

    Unanswered: error: Call to Undefined Function

    Hi..

    I have a function for convert to dozen.

    here is my code:

    PHP Code:
    <?php
        error_reporting
    (0);
      
    date_default_timezone_set("Asia/Singapore"); //set the time zone  
    $con mysql_connect('localhost''root','');

    if (!
    $con) {
        echo 
    'failed';
        die();
    }

    mysql_select_db("mes"$con);
    $Date_Shelve =date('Y-m-d H:i:s');  


    ?>
    <html>
    <head>
    <title>Job Order</title> 
    <link rel="stylesheet" type="text/css" href="kanban.css" />
    </head>
    <body>

    <div id="ddcolortabs">
    <ul>
    <li id="current"> <a href="SalesOrder.php" title="Sales Order"><span>Order Management</span></a></li>
    <li> <a href="ParameterSettings.php" title="Parameter Settings"><span>Parameter Settings</span></a></li>
    <li style="margin-left: 1px"><a href="kanban_report.php" title="WIP Report"><span>WIP Report</span></a></li>
    <li><a href="fsn.php" title="Finished Stock Note"><span>WMS FG</span></a></li>
    <li><a href="ReceivingMaterials.php" title="WMS RM"><span>WMS RM</span></a></li>  
    </ul>
    </div>
    <div id="ddcolortabs1">
    <ul>
    <li><a href="SalesOrder.php" title="Sales Order"><span>Sales Order</span></a></li>
    <li id="current"><a href="JobOrder.php" title="Job Order"><span>Job Order</span></a></li>    
    </ul>
    </div> 

    <div id="SR_date">

    <input type="hidden" name="Date_Shelve" id="Date_Shelve" value="<?php echo $Date_Shelve?>" size="16" readonly="readonly" style="border: none;">    
    </div>


    <?php
    //----approve button-----//
    $Approved = isset($_POST['priority']);
    if (
    $Approved)
    {
        
    $PO_No $_POST['PO_No'];  
        
    $ETD $_POST['ETD'];
        
    $SKUCode $_POST['SKUCode'];
        
    $Description $_POST['Description'];
        
    $POReq $_POST['POReq'];   
        
    $priority $_POST['priority'];
       
         
    $sql "SELECT SKUCode, Materials, Comp, Qty 
         FROM bom  WHERE SKUCode = '
    $SKUCode'";
         
    $res mysql_query($sql$con);
         
         
    $row mysql_fetch_assoc($res);
         
    $Materials $row['Materials'];
         
    $Qty $row['Qty'];
         
    $Comp $row['Comp'];
         
         
    $ReqQty $Qty $POReq;
         
    $sql "UPDATE bom SET ReqQty = '$ReqQty' WHERE SKUCode = '$SKUCode' AND Materials = '$Materials'";
    $resReqQty mysql_query($sql$con);


        
    $sql  =  "SELECT SUM(WEIGHING) AS WEIGHING_TOTAL, "
        
    $sql .=  "SUM(COMPOUNDING) AS COMPOUNDING_TOTAL, ";
        
    $sql .=  "SUM(EXTRUSION) AS EXTRUSION_TOTAL, ";                                                        
        
    $sql .=  "SUM(FORMING) AS FORMING_TOTAL, ";
        
    $sql .=  "SUM(DIPPING) AS DIPPING_TOTAL, ";
        
    $sql .=  "SUM(MOULDING) AS MOULDING_TOTAL ";
        
    $sql .=  "FROM MES_REPORT_OPEN WHERE SUBSTRING(LOT_CODE, 9) = '$Comp'";
        
        
        
    $result mysql_query($sql$con);
        
        
    $weighingTotal mysql_result($result0"WEIGHING_TOTAL");
        
    $weighingTotal convertToDozen($weighingTotal$Comp);
        
    $weighingAccum $weighingAccum $weighingTotal;
        
    $compoundingTotal mysql_result($result0"COMPOUNDING_TOTAL");
        
    $compoundingTotal convertToDozen($compoundingTotal$Comp);
        
    $compoundingAccum $compoundingAccum $compoundingTotal;
        
        
    $extrusionTotal mysql_result($result0"EXTRUSION_TOTAL");
        
    $extrusionTotal convertToDozen($extrusionTotal$Comp);
        
    $extrusionAccum $extrusionAccum $extrusionTotal
           
        
    $formingTotal mysql_result($result0"FORMING_TOTAL");
        
    $formingTotal convertToDozen($formingTotal$Comp);
        
    $formingAccum $formingAccum $formingTotal;
        
        
    $dippingTotal mysql_result($result0"DIPPING_TOTAL");
        
    $dippingTotal convertToDozen($dippingTotal$Comp);
        
    $dippingAccum $dippingAccum $dippingTotal;

        
    $virtualY $weighingTotal $compoundingTotal $extrusionTotal $formingTotal;
        
        
    $totalY $dippingTotal $virtualY;
        
        function 
    convertToDozen ($total,  $cmpdType) {
         switch (
    $cmpdType) {
            case 
    "P28" :
                
    $convTotal = (($total 1000) / 22.00) / 12;
            break;
            case 
    "P30" :
                
    $convTotal = (($total 1000) / 25.10) / 12;
            break;
            case 
    "P32" :
                
    $convTotal = (($total 1000) / 22.50) / 12;
            break;
            case 
    "P33" :
                
    $convTotal = (($total 1000) / 25.00) / 12;
            break;
            case 
    "P35" :
                
    $convTotal = (($total 1000) / 25.25) / 12;
            break;
            case 
    "P35M" :
                
    $convTotal = (($total 1000) / 22.60) / 12;
            break;
            case 
    "P35W" :
                
    $convTotal = (($total 1000) / 22.50) / 12;
            break;
            case 
    "P38" :
                
    $convTotal = (($total 1000) / 26.70) / 12;
            break;
            case 
    "P41" :
                
    $convTotal = (($total 1000) / 24.80) / 12;
            break;
            case 
    "P42" :
                
    $convTotal = (($total 1000) / 18.90) / 12;
            break;
            case 
    "P43" :
                
    $convTotal = (($total 1000) / 25.00) / 12;
            break;
            case 
    "P46" :
                
    $convTotal = (($total 1000) / 27.00) / 12;
            break;
            case 
    "P47" :
                
    $convTotal = (($total 1000) / 27.60) / 12;
            break;
        }
         return 
    round($convTotal2);        
    }
    }
    else{
        
    }
     


    $sql "SELECT jo_number, ETD, PO_No, SKUCode, Description, POQty, Priority
    FROM job_order ORDER BY jo_number, ETD"
    ;
    $res mysql_query($sql,$con);
    ?>
    <div id="kanban_table" style="overflow:auto; height:215px;"> 
    <table>
    <th> JO No.</th>
    <th> ETD </th>
    <th> PO No. </th>
    <th> SKU Code </th>
    <th> Description </th>
    <th> PO Req </th>
    <th> Priority</th>
    <?php
    $sql 
    "SELECT ETD, PO_No, SKUCode, Description, POReq 
    FROM sales_order  WHERE NOT EXISTS (SELECT PO_No FROM job_order WHERE job_order.PO_No = sales_order.PO_No) ORDER BY ETD, PO_No "
    ;
    $res_so mysql_query($sql$con);
    while(
    $row mysql_fetch_assoc($res_so)){ 
    echo 
    "<form name='joborder_form' action='' method='post'>";   
    $PO_No $row['PO_No'];    
    echo 
    "<tr>
    <td><input type='text' value='' style='border:none;' size='10'></td>
    <td><input type='text' name='ETD' id='ETD' value='
    $row[ETD]' style='border:none;' size='10'></td> 
    <td><input type='text' name='PO_No' id='PO_No' value='
    $row[PO_No]' style='border:none;' size='30'></td>
    <td><input type='text' name='SKUCode' id='SKUCode' value='
    $row[SKUCode]' style='border:none;' size='15'></td>
    <td><input type='text' name='Description' id='Description' value='
    $row[Description]' style='border:none;' size='35'></td>
    <td><input type='text' name='POReq' id='POReq' value='
    $row[POReq]' style='border:none;' size='10'></td> 
    <td><input type='submit' name='priority' value='Approved' id='priority'></td>
    </tr>"
    ;
    echo 
    "</form>";
    }
    echo 
    "</table>";
    echo 
    "</div>";    




    echo 
    "<div style='overflow:auto; height:215px;'>";
    echo 
    "<table>";
    while(
    $row_job mysql_fetch_assoc($res)){
        echo 
    "<tr>
        <td><input type='text' name='JO_No_' id='JO_No_' value='
    $row_job[jo_number]' style='border:none;width:auto;' size='10'></td>
        <td><input type='text' name='ETD_' id='ETD_' value='
    $row_job[ETD]' style='border:none;width:auto;' size='10'></td> 
        <td><input type='text' name='PO_No_' id='PO_No_' value='
    $row_job[PO_No]' style='border:none;' size='30'></td>
        <td><input type='text' name='SKUCode_' id='SKUCode_' value='
    $row_job[SKUCode]' style='border:none;' size='15'></td>
        <td><input type='text' name='Description_' id='Description_' value='
    $row_job[Description]' style='border:none;' size='35'></td>
        <td><input type='text' name='POReq_' id='POReq_' value='
    $row_job[POQty]' style='border:none;width:auto;' size='10'></td> 
        <td><input type='text' name='priority_' value='
    $row_job[Priority]' id='priority_' style='border:none;width:auto;' size='10'></td> 
        </tr>" 
    ;
    }
    echo 
    "</table>";
    echo 
    "</div>"  
    ?>

    </body>
    </html>
    but I when I echo this:
    PHP Code:
     echo $weighingTotal
    No result, then when I debug my code I got an error: Call to undefined function.

    I can’t configured out where in my code was wrong?

    Any help is highly appreciated.

    Thank you

  2. #2
    Join Date
    Apr 2012
    Posts
    12
    In which row?

  3. #3
    Join Date
    Dec 2010
    Posts
    136
    row = 84

    Code:
        $weighingTotal = convertToDozen($weighingTotal, $Comp);
    Thank you

  4. #4
    Join Date
    Apr 2012
    Posts
    12
    The problem is that you define the function after you use it.
    put the function on top then it should work.

  5. #5
    Join Date
    Dec 2010
    Posts
    136
    Thank you. I tried it and it works now

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    also whilst developing make it easier for yuourself by setting an appropriate error reporting level
    PHP: error_reporting - Manual
    I'd rather be riding on the Tiger 800 or the Norton

  7. #7
    Join Date
    Dec 2010
    Posts
    136
    i tried:

    Code:
    if(empty($_FILES['file']['tmp_name']['error'])){
         //$dom = new DOMDocument();
         //$dom = DOMDocument::load('SalesOrder.xml');
         $dom = new DOMDocument();
    $dom->load('SalesOrder.xml');
    $dom->saveXML();
       
      // $dom = DOMDocument::load($_FILES['file']['tmp_name']);
      //  $dom = DOMDocument::__construct();           
          $rows = $dom->getElementsByTagName('Row');
          global $last_row;
          $last_row = false;
          $first_row = true;
    No error but it did not save to my database the data

    Thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •