Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Posts
    713
    Thanks
    165
    Thanked 0 Times in 0 Posts

    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
    Regular Coder
    Join Date
    Aug 2010
    Posts
    713
    Thanks
    165
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by iBall View Post
    The error message should have given you the name of the undefined function and the line number where the error occurred.

    But in any case. from your post it might be this line

    PHP Code:
    $weighingTotal convertToDozen($weighingTotal$Comp); 
    So either convertToDozen() does not exist or is not c
    ontained in your page code or any of your include/require file(s).
    my function is on below, its same page.

    I think I will put my function inside my if condition.?

    Thank you

  • #3
    Regular Coder
    Join Date
    Aug 2010
    Posts
    713
    Thanks
    165
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by iBall View Post
    ok I see the function now. There is no need to put it inside the IF. You can put all your functions at the very bottom of the page or in a require() file, out of the way of the rest of the code.

    But it would now help if you copy and paste and then post the entire error message including the line number where the error happened you got for the undefined function.

    Thank you. I tried it and it works now


  •  

    Posting Permissions

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