1

I am building a shopping cart, and right now I am working on the categories system of the products. I have to add categories from the admin panel which works fine.

Now, when I want to update the category, the page keeps loading and after 3-4 minutes, it shows that the service temporarily unavailable error in mozilla firefox and 404 error in chrome.

When contacted to the hosting provider, Here's what he sent in the mail:

The issue that you are facing is mainly due to saturation of the number of fcgi processes allocated for your account. We allow 3 child process and for each child process, 256 worker processes. Once that limit is breached, you see that kind of error. However, those errors are auto-fixed once the number of processes reduce.

--
[Thu Feb 19 08:29:30 2015] [warn] [client My-IP-Address] mod_fcgid: can't apply process slot for /usr/local/cpanel/cgi-sys/php-fcgi, referer: http://www.example.com/nbs/Administrators/Categories/
[Thu Feb 19 08:29:31 2015] [warn] [client My-IP-Address] mod_fcgid: can't apply process slot for /usr/local/cpanel/cgi-sys/php-fcgi, referer: http://www.example.com/nbs/Administrators/Categories/
[Thu Feb 19 08:29:32 2015] [warn] [client My-IP-Address] mod_fcgid: can't apply process slot for /usr/local/cpanel/cgi-sys/php-fcgi, referer: http://www.example.com/nbs/Administrators/Categories/
[Thu Feb 19 08:29:32 2015] [warn] [client My-IP-Address] mod_fcgid: can't apply process slot for /usr/local/cpanel/cgi-sys/php-fcgi, referer: http://www.example.com/nbs/Administrators/Categories/
[Thu Feb 19 08:29:32 2015] [warn] [client My-IP-Address] mod_fcgid: can't apply process slot for /usr/local/cpanel/cgi-sys/php-fcgi, referer: http://www.example.com/nbs/Administrators/Categories/
[Thu Feb 19 08:29:33 2015] [warn] [client My-IP-Address] mod_fcgid: can't apply process slot for /usr/local/cpanel/cgi-sys/php-fcgi, referer: http://www.example.com/nbs/Administrators/Categories/
[Thu Feb 19 08:29:33 2015] [warn] [client My-IP-Address] mod_fcgid: can't apply process slot for /usr/local/cpanel/cgi-sys/php-fcgi, referer: http://www.example.com/nbs/Administrators/Categories/
[Thu Feb 19 08:29:33 2015] [warn] [client My-IP-Address] mod_fcgid: can't apply process slot for /usr/local/cpanel/cgi-sys/php-fcgi, referer: http://www.example.com/nbs/Administrators/Categories/
--

In order to fix the issue permanently, you need to optimize your codes or please go for VPS packages.

Here's the php code index.php page of the categories folder

<form method="POST" action="http://www.example.com/nbs/ActionFiles/DeleteSelectedCategories.php">   
    <div class="table-responsive">
        <table border="1" class="table table-bordered table-striped">
            <thead>
                <tr>
                    <th class="text-center"><input type="checkbox" id="all" name="deleteCat[]"></th>
                    <th class="text-center">Category-Name</th>
                    <th class="text-center">Action</th>
                </tr>
                <tr>
                    <th>&nbsp;</th>
                    <th>
                        <input class="filter form-control input-sm" name="Cat-Name" placeholder="Cat-Name" data-col="Category-Name">
                    </th>
                    <th>&nbsp;</th>
                </tr>
            </thead>
            <tbody>

                <?php
                require_once '../../Classes/class.Validation.php';
                $validate = new Validation();
                $qu = "SELECT CatId, CatName FROM categories";
                $validate->Query($qu);
                if ($validate->NumRows()) {
                    while ( $row = $validate->FetchAllDatas() ) {
                        echo '<tr>
                        <td class="text-center"><input type="checkbox" id="'.$row["CatId"].'" value="'.$row["CatId"].'" name="deleteCat[]"></td>
                        <td>'.$row['CatName'].'</td>
                        <td>
                            <a href="http://www.example.com/nbs/Administrators/Categories/UpdateCategory.php?id='.$row["CatId"].'">UPDATE</a><br /><a href="http://www.example.com/nbs/ActionFiles/DeleteCategory.php?id='.$row["CatId"].'">DELETE</a>
                        </td></tr>';
                    }
                }
                ?>                          
            </tbody>
            <tfoot>
                <th class="text-center"><input type="checkbox" id="all" name="deleteCat[]"></th>
                <th class="text-center">Category-Name</th>
                <th class="text-center">Action</th>
            </tfoot>
        </table>
    </div>
    <input type="submit" id="del" name="btnCatDelete" value="DELETE" class="btn btn-link pull-right">
</form>

Please tell me where have I made the mistake. Thanks in advance.

EDIT 1: UpdateCategory.php

<?php
session_start();
if (!isset($_SESSION['Administrator']) && $_SESSION['Administrator'] == "") {
    header("Location: http://www.example.com/nbs/Administrators/");
    exit();
}
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <title>Benefit Sqaure Administrator - Add Products</title>

    <link href="http://www.example.com/nbs/BootStrap/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
    <link href="http://www.example.com/nbs/StyleSheets/toastr.css" type="text/css" rel="stylesheet" />
    <link href="http://www.example.com/nbs/StyleSheets/styles.css" type="text/css" rel="stylesheet" />
    <link href="http://www.example.com/nbs/Images/bs-favicon.png" rel="icon" type="image/x-icon" />

    <script src="http://www.example.com/nbs/JavaScripts/Modernizr.js"></script>
</head>
<body style="margin-top: 75px;">
    <?php
    require_once '../../PHP_Includes/AdminNavs.php';

    require_once '../../Classes/class.Validation.php';
    $validate = new Validation();

    $catName = $catAvail = $catDesc = $catParent = "";
    $catSeoUrl = $catMetaTitle = $catMetaDesc = $catMetaKeyWords = "";
    $catTaxPercent = "";
    $error = 0;

    if (isset($_GET['id']) && $_GET['id'] != "") {
        $q = "SELECT * FROM categories WHERE CatId = '".$_GET['id']."' ";
        $validate->Query($q);
        if ($validate->NumRows()) {
            while ($row = $validate->FetchAllDatas()) {
                $catName = $row['CatName'];
                $catDesc = $row['CatDescription'];
                $catParent = $row['CatParentId'];
                $catAvail = $row['CatDisplay'];

                $catSeoUrl = $row['CatSeoUrl'];
                $catMetaTitle = $row['CatMetaTitle'];
                $catMetaDesc = $row['CatMetaDescription'];
                $catMetaKeyWords = $row['CatMetaKeyWords'];

                $catTaxPercent = $row['CatTaxPercent'];
            }
        }
    }
    ?>

    <div class="container-fluid">
        <div class="tabbable">
            <ul class="nav nav-tabs">
                <li class="active">
                    <a href="#general" data-toggle="tab">General</a>
                </li>               
                <li>
                    <a href="#marketing" data-toggle="tab">Marketing</a>
                </li>
                <li>
                    <a href="#account" data-toggle="tab">Accounts</a>
                </li>
            </ul>
            <div class="tab-content" style="margin-top: 25px;">
                <div class="container-fluid tab-pane active" id="general">
                    <div class="panel panel-primary">
                        <div class="panel-heading">
                            <h4 class="text-center">Update Product Details</h4>
                        </div>
                        <div class="panel-body">
                            <form class="form-horizontal" action="http://www.example.com/nbs/ActionFiles/UpdateCategories.php?id=<?php echo $_GET['id']; ?>" method="POST">

                                <div class="form-group">
                                    <div class="col-md-2">
                                        <label id="prodName" for="productName">Category Name:</label>
                                    </div>
                                    <div class="col-md-8">
                                        <input type="text" name="updCatName" value="<?php echo $catName; ?>" class="form-control input-sm" id="productName" />
                                    </div>
                                    <div class="col-md-2">
                                        <span class="glyphicon glyphicon-question-sign" style="margin-top: 5px;" data-toggle="tooltip" data-placement="right" title="The name of the category that you want to be displayed. It should contain only letters"></span>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class="col-md-2">
                                        <label id="prodAvail" for="productAvailability">Parent Category:</label>
                                    </div>
                                    <div class="col-md-8">
                                        <select name="updCatParent" class="form-control input-sm" id="productAvailability">
                                            <?php
                                            $name = "";
                                            $query = "SELECT CatName, CatParentId FROM categories WHERE CatParentId = '".$catParent."'";
                                            $validate->Query($query);
                                            while ($row = $validate->FetchAllDatas()) {
                                                if ($row['CatParentId'] == 0) {
                                                    $name = "Parent Category";
                                                } else {
                                                    $que = "SELECT c.CatName, cn.CatParentId FROM categories c, categories cn WHERE cn.CatParentId = c.CatId AND cn.CatParentId = '".$catParent."'";
                                                    $validate->Query($que);
                                                    $name = $validate->FetchAssoc('CatName');
                                                }
                                            }



                                            ?>
                                            <option value="<?php echo $catParent; ?>"><?php echo $name . " -- selected"; ?></option>
                                            <?php
                                            $query = "SELECT CatId, CatName FROM categories ORDER BY CatName";
                                            $validate->Query($query);
                                            while ($row = $validate->FetchAllDatas()) {
                                                echo '<option value="'.$row['CatId'].'">'.$row['CatName'].'</option>';
                                            }
                                            ?>
                                        </select>
                                    </div>
                                    <div class="col-md-2">
                                        <span class="glyphicon glyphicon-question-sign" style="margin-top: 5px;" data-toggle="tooltip" data-placement="right" title="The availability of the category for the users"></span>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class="col-md-2">
                                        <label id="prodAvail" for="productAvailability">Category Availability:</label>
                                    </div>
                                    <div class="col-md-8">
                                        <select name="updCatAvail" class="form-control input-sm" id="productAvailability">
                                            <option value="<?php echo $catAvail; ?>"><?php echo $catAvail . " -- selected"; ?></option>
                                            <option value="-1">Select Category Availability</option>
                                            <option value="Enabled">Enabled</option>
                                            <option value="Disabled">Disabled</option>
                                        </select>
                                    </div>
                                    <div class="col-md-2">
                                        <span class="glyphicon glyphicon-question-sign" style="margin-top: 5px;" data-toggle="tooltip" data-placement="right" title="The availability of the category for the users"></span>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class="col-md-2">
                                        <label for="productDes">Category Description</label>
                                    </div>
                                    <div class="col-md-8">
                                        <textarea name="catDescription" id="productDes"><?php echo $catDesc; ?></textarea>
                                    </div>
                                    <div class="col-md-2">
                                        <span class="glyphicon glyphicon-question-sign" style="margin-top: 5px;" data-toggle="tooltip" data-placement="right" title="The description of the category for the users"></span>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class="col-md-2"></div>
                                    <div class="col-md-8">
                                        <input type="submit" name="btnUpdGenTabCate" id="btnUpdGenTabCate" value="Update Product" class="form-control input-lg btn btn-block btn-primary prdBtnSubmit">
                                    </div>
                                    <div class="col-md-2"></div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>

                <div class="container-fluid tab-pane" id="marketing" style="margin-top: 25px;">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h4 class="text-center">Enter Marketing Details</h4>
                        </div>
                        <div class="panel-body">
                            <form class="form-horizontal" action="http://www.example.com/nbs/ActionFiles/UpdateCategoriesMkt.php?id=<?php echo $_GET['id']; ?>" method="POST" >
                                <div class="form-group">
                                    <div class="col-md-2">
                                        <label for="seoURL">SEO URL:</label>
                                    </div>
                                    <div class="col-md-8">
                                        <input type="text" name="catSeoUrl" id="seoURL" class="form-control input-sm" value="<?php echo $catSeoUrl; ?>" />
                                    </div>
                                    <div class="col-md-2"></div>
                                </div>

                                <div class="form-group">
                                    <div class="col-md-2">
                                        <label for="metTitle">Meta Title:</label>
                                    </div>
                                    <div class="col-md-8">
                                        <input type="text" name="catMetaTitle" id="metTitle" class="form-control input-sm"  value="<?php echo $catMetaTitle; ?>"/>
                                    </div>
                                    <div class="col-md-2"></div>
                                </div>

                                <div class="form-group">
                                    <div class="col-md-2">
                                        <label for="metDesc">Meta Description:</label>
                                    </div>
                                    <div class="col-md-8">
                                        <textarea name="catMetaDescription" id="metDesc" class="form-control input-sm" ><?php echo $catMetaDesc; ?></textarea>
                                    </div>
                                    <div class="col-md-2"></div>
                                </div>

                                <div class="form-group">
                                    <div class="col-md-2">
                                        <label for="metKeyWords">Meta Keywords:</label>
                                    </div>
                                    <div class="col-md-8">
                                        <input type="text" name="catMetaKeyWords" id="metKeyWords" class="form-control input-sm" value="<?php echo $catMetaKeyWords; ?>" />
                                    </div>
                                    <div class="col-md-2"></div>
                                </div>

                                <div class="form-group">
                                    <div class="col-md-2"></div>
                                    <div class="col-md-8">
                                        <input type="submit" name="btnCatMrktgTabUpdate" value="Update Marketing" class="btn btn-primary btn-block">
                                    </div>
                                    <div class="col-md-2"></div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>

                <div class="container-fluid tab-pane" id="account" style="margin-top: 25px;">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h4 class="text-center">Enter Commission Details</h4>
                        </div>
                        <div class="panel-body">
                            <form method="POST" class="form-horizontal" action="http://www.example.com/nbs/ActionFiles/UpdateCategoriesTax.php?id=<?php echo $_GET['id']; ?>" >
                                <div class="form-group">
                                    <div class="col-md-2">
                                        <label for="modCommission">Tax Percentage:</label>
                                    </div>
                                    <div class="col-md-8">
                                        <input type="text" name="catTaxPercent" id="modCommission" class="form-control input-sm" value="<?php echo $catTaxPercent; ?>" />
                                    </div>
                                    <div class="col-md-2"></div>
                                </div>

                                <div class="form-group">
                                    <div class="col-md-2"></div>
                                    <div class="col-md-8">
                                        <input type="submit" name="btnUCommTabUpdate" value="Update Commission" class="btn btn-primary btn-block">
                                    </div>
                                    <div class="col-md-2"></div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Include all the JavaScript File(s) -->
    <script src="http://www.example.com/nbs/JavaScripts/jquery-latest.min.js"></script>
    <script src="http://www.example.com/nbs/JavaScripts/toastr.min.js"></script>
    <script src="http://www.example.com/nbs/JavaScripts/Main.js"></script>
    <script src="http://www.example.com/nbs/JavaScripts/multifilter.min.js"></script>
    <script src="http://www.example.com/nbs/BootStrap/js/bootstrap.min.js"></script>
    <script src="http://www.example.com/nbs/ckeditor/ckeditor.js"></script>
    <script type="text/javascript">
        CKEDITOR.replace('productDes');
    </script>
</body>
</html>
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Saiyan Prince
  • 3,930
  • 4
  • 28
  • 71

1 Answers1

0

Well, that happens when hosting company setup a hard limit to the resources on server. You need to change your hosting provider in which case.

Anyways, How many rows your query is returning?

  • As of now just 20 (includes both - parent and child) – Saiyan Prince Feb 20 '15 at 10:10
  • 20 rows should be fine i guess. I think the problem is somewhere else then. Can you comment this query and loop part from code for a moment and check if the issue is still there? – Manish Sonwal Feb 20 '15 at 10:24
  • For your information, I can only update the parent category from the front end (admin panel) and not the child category – Saiyan Prince Feb 20 '15 at 10:26
  • What i mean is, the problem is maybe not in the part of code you provided here. – Manish Sonwal Feb 20 '15 at 10:42
  • That is the index page for the categories. I have to select any one of them to update. And the error is on the index page only. UpdateCategory.php can not load at all for the child category while for the parent category, yes, it can load. – Saiyan Prince Feb 20 '15 at 10:44