Click here to Skip to main content
14,739,346 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Well, I am making the eCommerce web application and I am trying to update the categories from the admin panel.

I have 2 pages (index.php and UpdateCategory.php) in categories folder which lies inside the admin folder in the root directory.

Now, I have come across the error of 503 - Intermittent service unavailable whenever I click on the update button which is in the index.php file. This happens only with the child category and not the parent category.

Here's the index.php file:
<?php
$table = '';
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() ) {
        $table .= '<tr>';
        $table .= '<td class="text-center">';
        $table .= '<input type="checkbox" name="deleteCat[]" value='.$row["CatId"].'>';
        $table .= '</td>';
        $table .= '<td>';
        $table .= $row["CatName"];
        $table .= '</td>';
        $table .= '<td>';
        $table .= '<a href="//www.example.com/nbs/Administrators/Categories/UpdateCategory.php?id='.$row["CatId"].'">UPDATE</a>';
        $table .= '</td>';
        $table .= '<tr>';
    }
}
echo $table;
?>


Whenever I click on the UPDATE link in the index.php file, UpdateCategory.php is requested. The browser responses with the page perfectly only for the parent category and does not responses to the child category. This error didn't occurred at all before adding .htaccess file in the root directory and I had added .htaccess file just few days back (maybe 3-4 days).

Here's the .htacccess file:
RewriteEngine On

RewriteRule ^product/([^/.]+)/?$ product.php?code=$1 [L]

RewriteRule ^beneficiary/([^/.]+)/?$ beneficiary.php?code=$1 [L]

RewriteRule ^categories/([^/.]+)/?$ categories.php?name=$1 [L]

RewriteRule ^category/([^/.]+)/?$ category.php?name=$1 [L]


The categories table have total 18 categories (inclusive of both parent and child)

I am also told to optimize the php code and also the queries. How do I optimize the php code and the mysqli queries ?

Kindly help me in solving this.

Any help is greatly appreciated.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900