Debugging PHP script

Hello good people i have a visitor’s_checkout.php page where i have created an action method to bill.php where again bill.php has an action method linked to calculation.php now the problem i am facing is when i try to view my bill it throws an error!

Here is my visitor’s_checkout.php

<div class="main">
        <center><h2>Visitors Record</h2></center>
        <form method="post" action="Bill.php">
            <table align="center" border="1" style="width:90%; margin-top:8px;">
                <tr>
                <th>Booking ID</th>
                <td colspan="2"><?php echo "OTPC-TH-0".$_SESSION['row']["id"] ?></td><td rowspan="10" style=" padding: auto; "><center><img height="180px" src="webcam/<?php echo $_SESSION['img']['image'] ?>"></center></td>
                </tr>
                <tr>
                <th>Visitor's Name</th><td colspan="2"><?php echo  $_SESSION['row']["V_name"] ?></td>
                </tr>
                <tr>
                    <th><?php echo $_SESSION['row']["G_type"]?>'s Name</th><td colspan="2"> <?php echo $_SESSION['row']["G_name"]?></td>
                </tr>
                 <tr>
                 <th>Date of birth</th><td colspan="2"><?php $dob = strtotime($_SESSION['row']["Dob"]); echo date("d F' Y", $dob)?>  </td>  
                </tr>
                <tr>
                 <th>Company</th>
                <td colspan="2"><?php echo $_SESSION['row']["Company"]?></td>  
                </tr>
                <tr>
                 <th>Mobile Number</th>
                <td colspan="2"><?php echo $_SESSION['row']["Mobile_num"]?></td>  
                </tr>
                 <tr>
                <th>Gender</th><td colspan="2"><?php echo $_SESSION['row']["Gender"]?></td>
                </tr>
                <tr>
                 <th>Check in Date</th>
                <td colspan="2"><?php $c_in = strtotime($_SESSION['row']["C_in"]); echo date("l, d F' Y", $c_in)?></td>
                </tr>
                <tr>
                <th>Check Out Date</th>
                <td colspan="2"><?php $c_out = strtotime($_SESSION['row']["C_out"]); echo date("l, d F' Y", $c_out)?></td>  
                </tr>
                <tr>
                <th>Extended Date</th>
                <td colspan="2"><?php $ext_date = strtotime($_SESSION['row']["Date_extended"]); echo date("l, d F' Y", $ext_date)?></td>  
                </tr>
                <tr>
                <th> Room Type:</th>
                  <td><?php echo $_SESSION['room']["Room_type"]?></td>
                <th style="width:75px;">  Room No.:
                </th> <td><?php echo $_SESSION['room']["Room_num"]?></td> 
                </tr>
                <tr>
                <th>Email Address</th>
                <td colspan="3"><?php echo $_SESSION['row']["mail"]?></td >
                </tr>
                <tr>
                <th>Purpose</th>
                <td colspan="3"><?php echo $_SESSION['row']["Purpose"]?></td>  
                </tr>
                <tr>
                <th>Address</th>
                <td colspan="3"><?php echo $_SESSION['row']["Address"]?></td>
                </tr>
                <tr>
                   <th>Country</th> 
                    <td colspan="3"><?php echo $_SESSION['row']["Country"]?></td>
                </tr>
                <tr>
                    <th>State</th>
                     <td colspan="3"><?php echo $_SESSION['row']["State"]?>
                    </td>
                </tr>
               
                <tr>
                 <th>City</th><td colspan="3"><?php echo $_SESSION['row']["City"]?> </td> </tr>
                <tr>
                    <th>PIN</th><td colspan="3"><?php echo $_SESSION['row']["PIN"]?></td>  
                </tr>
                <tr>
                    <th>ID Proof</th><td colspan="3"><?php echo $_SESSION['img']["id_type"]." No. ".$_SESSION['img']["id_num"] ?></td>  
                </tr>
                
                <tr>
                <th>Reference</th><td colspan="3"><?php echo $_SESSION['row']["Acc_1"]?> </td>
                </tr>
                <tr>
                <th colspan="4" align="left">Accompany Details</th>
                </tr>
                <tr>
                <th>1.</th><td colspan="3"><?php echo $_SESSION['row']["Acc_2"]?> </td>
                </tr>
                <tr>
                <th>2.</th><td colspan="3"><?php echo $_SESSION['row']["Acc_3"]?> </td>
                </tr>
                
                <tr>
               
                    <td colspan="100%" align="center"><input name="Confirm" type="submit"  value="Confirm"/></td>
                
                </tr> 
                
            </table>
        </form>
   </div>
    </div>
    
<script>
function printDiv(printableArea) {
     var printContents = document.getElementById(printableArea).innerHTML;
     var originalContents = document.body.innerHTML;

     document.body.innerHTML = printContents;

     window.print();

     document.body.innerHTML = originalContents;
}
</script>
    <center><a href="profile.php"><button class="button">Home</button></a></center>
</body>
</html>

This part my bill.php

 <form method="POST" action="calculation.php" enctype="multipart/form-data">
        <table align="center" border="1" border-collapse="collapse" style="width: 70%; border-collapse: collapse; border: 1px #000 solid ">
           
                <tr>
                    <th style=" text-align: left;" >1. Check in Date</th>
                 <td align="right" colspan="1"><?php $c_in = strtotime($row["C_in"]); echo date("l, d F' Y", $c_in)?></td>
                </tr>
                <tr>
                <th align="left" >2. Check Out Date</th>
                
                <td align="right" colspan="1"><?php $Ext_date = strtotime($row["Date_extended"]); echo date("l, d F' Y", $Ext_date)?></td>  
                </tr>
               <?php
               date_default_timezone_set('Asia/Kolkata');
                $t=time();
                $t1 = date('Y-m-d H:i:s', $t);
                $t2 = date('Y-m-d', $t);
                $curr_date = strtotime($t2);
                if($Ext_date>$curr_date)
                {
                    $cost_date = $curr_date;
                }
             else 
                 {
                    $cost_date = $Ext_date;
                 }
               ?>
                <tr>
                    <th style=" text-align: left">3. Total Days Stay</th>
                <td id="day" align="right" colspan="1"><?php 
                $day_stay = (int)(($cost_date - strtotime($row["C_in"]))/86400) ; 
                if ($day_stay==0)
                {
                    $_SESSION['day'] =1;
                }
             else 
                 {
                    $_SESSION['day']=$day_stay;
                 }
                
                echo $_SESSION['day'] ;
                  ?></td >
                </tr>
                <tr>
                    <th style=" text-align: left;">4. Rent</th>
                <td align="right" colspan="1" ><input type='number' Name="rate" id='rate' max="99999" maxlength="5" value='0.00' style="font-size: 10pt; margin-bottom: 1px; margin-top: 1px;"/>  /-</td>
                
                </tr>
                 <tr>
                     <th style=" text-align: left">5. Discount</th> 
                   <td colspan="1" align="right"><input type="number" max="99" Name="discount" step='0.01' value='0.00' id="discount" style="font-size: 10pt; margin-bottom: 1px; margin-top: 1px;">%</td>
                </tr>
                <tr>
                    <th style=" text-align: left; padding-right: 0px">6. Additional Charges<br><textarea type="textarea" name="add_charge_type" maxlength="100" rows="1" cols="40" style=" margin-right: -50px;"></textarea></th> 
                   <td colspan="1" align="right"><input type="number" max="9999" Name="add_charge" step='0.01' value='0.00' id="add_charge" > /-</td>
                </tr>
                 <tr>
                     <th style=" text-align: left">7. Add: CGST </th>
                     <td colspan="1" align="right"><input type="number" maxlength="2" size="2" Name="cgst" step='0.01' value='0.00' id="cgst" style=" font-size: 10pt; margin-bottom: 1px; margin-top: 1px;" >%</td>
                </tr>
                <tr>
                    <th style=" text-align: left">8. Add: SGST </th>
                    <td colspan="1" align="right"><input type="number" maxlength="2" size="2" Name="sgst" step='0.01' value='0.00' placeholder='0.00' id="sgst" style="font-size: 10pt; margin-bottom: 1px; margin-top: 1px;" >%</td>
                </tr>
                <tr>
                    <th style=" text-align: left">9. Add: TCS </th>
                    <td colspan="1" align="right" style=" padding-bottom: 1px;"><input type="number" maxlength="2" size="2" Name="tcs" value='0.00' id="tcs" style="font-size: 10pt; margin-bottom: 1px; margin-top: 1px;" >%</td>
                </tr>
                <tr>
                    <th style=" text-align: left">10. PAN:</th><td style=" text-align: right; padding-right: 15px;"><input type="text" name="PAN" style="text-transform: uppercase; font-size: 10pt; margin-bottom: 1px; margin-top: 1px;"></td>
                </tr>
               
<!--                               <tr>
                                   <th>Payment Remarks</th><td colspan="1"><input type="text" Name="payment" id="payment" rows="1" cols="50" maxlength="150" placeholder="Enter payment remarks..."></td>
                               </tr>-->
                <tr>
                    <td colspan="3" align="center"><input type="submit" name="save" value="View"/></td>
                </tr>
                
            </table>
        </form>
   </div>
        
    <center><a href="profile.php"><button class="button">Home</button></a></center>
</body>
</html>
<?php
if(isset($_POST['save'])){ 
    $_SESSION['day'] = $_SESSION['day'];
    $_SESSION['room_rate'] = $_POST['rate']; 
    $_SESSION['tot_rent'] = $_SESSION['room_rate']*$_SESSION['day'];
    $_SESSION['discount'] = $_POST['discount'];
    $discount = ($_SESSION['tot_rent']*$_SESSION['discount'])/'100';
    $_SESSION['tot_discount'] = $discount;
    $_SESSION['cgst'] = $_POST['cgst'];
    $_SESSION['sgst'] = $_POST['sgst'];
    $tcs = $_POST['tcs'];
    $add_charges = $_POST['add_charge'];
    $_SESSION['add_charge_type'] = $_POST['add_charge_type'];
    $_SESSION['add_charge'] = $add_charges;
    $_SESSION['tcs_per'] = $_POST['tcs'];
    $_SESSION['tcs'] = ($_SESSION['tot_rent']-$discount+$add_charges)*$tcs/'100';
    $_SESSION['tot_cgst'] = ($_SESSION['tot_rent']-$discount+$add_charges)*$_SESSION['cgst']/'100';
    $_SESSION['tot_sgst'] = ($_SESSION['tot_rent']-$discount+$add_charges)*$_SESSION['sgst']/'100';
    $num = ($_SESSION['tot_rent']-$discount+$add_charges)+$_SESSION['tot_cgst']+$_SESSION['tot_cgst']+$_SESSION['tcs'];
    $_SESSION['total'] = $num;
//    $_SESSION['payment'] = $_POST['payment'];
    $_SESSION['PAN'] = $_POST['PAN'];
 
    $f = new NumberFormatter("en", NumberFormatter::SPELLOUT);
    $f->setTextAttribute(NumberFormatter::DEFAULT_RULESET, "%spellout-numbering-verbose");
    $_SESSION['num'] = $f->format($num);
// = numberTowords("$num");
//header('location: Bill_preview.php');
echo "<script type='text/javascript'> document.location = 'Bill_preview.php'; </script>";
                        }

?>

This is my calculation.php

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
session_start();

if(isset($_POST['save']))
    { 
    $_SESSION['day'] = $_SESSION['day'];
    $_SESSION['room_rate'] = $_POST['rate']; 
    $_SESSION['tot_rent'] = $_SESSION['room_rate']*$_SESSION['day'];
    $_SESSION['discount'] = $_POST['discount'];
    $discount = ($_SESSION['tot_rent']*$_SESSION['discount'])/100;
    $_SESSION['tot_discount'] = $discount;
    $_SESSION['cgst'] = $_POST['cgst'];
    $_SESSION['sgst'] = $_POST['sgst'];
    $tcs = $_POST['tcs'];
    $add_charges = $_POST['add_charge'];
    $_SESSION['add_charge_type'] = $_POST['add_charge_type'];
    $_SESSION['add_charge'] = $add_charges;
    $_SESSION['tcs_per'] = $_POST['tcs'];
    $_SESSION['tcs'] = ($_SESSION['tot_rent']-$discount+$add_charges)*$tcs/100;
    $_SESSION['tot_cgst'] = ($_SESSION['tot_rent']-$discount+$add_charges)*$_SESSION['cgst']/100;
    $_SESSION['tot_sgst'] = ($_SESSION['tot_rent']-$discount+$add_charges)*$_SESSION['sgst']/100;
    $num = ($_SESSION['tot_rent']-$discount+$add_charges)+$_SESSION['tot_cgst']+$_SESSION['tot_cgst']+$_SESSION['tcs'];
    $_SESSION['total'] = $num;
//    $_SESSION['payment'] = $_POST['payment'];
    $_SESSION['PAN'] = $_POST['PAN'];
 
    $f = new NumberFormatter("en", NumberFormatter::SPELLOUT);
    $f->setTextAttribute(NumberFormatter::DEFAULT_RULESET, "%spellout-numbering-verbose");
    $_SESSION['num'] = $f->format($num);
// = numberTowords("$num");
header('location: Bill_preview.php');
}

?>

Error shows


Fatal error: Uncaught Error: Class 'NumberFormatter' not found in /var/www/html/oams_dev/calculation.php:30 Stack trace: #0 {main} thrown in /var/www/html/oams_dev/calculation.php on line 30

Kindly help…

Thank you guys i have found the solution after an update for intl sudo apt-get install php7.0-intl.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.