PHP Notice: Undefined index: p

I have this PHP Notice: Undefined index: p in …/public_html/catalog/controller/common/pagination.php on line 24, on my website. I managed somehow to stop it, but is a kind of “Frankenstein” solution gathered from “dead” posts on different forums, because i wasn’t able to find a real solution.
Could anyone be so kind to help? I have no knowledge of PHP programming but I’m good at copy-paste. :slight_smile:

Here is the default script:


    if (isset($_GET["sort"])) $sort = $_GET["sort"]; else $sort = 'p.date_added';
    if (isset($_GET["order"])) $order = $_GET["order"]; else $order = 'DESC';
    if (isset($_GET["category_id"])) $order = $_GET["category_id"]; else $category_id = 0;
    if (isset($_GET["c"])) $category = $_GET["c"]; else $category = 0;
    if (isset($_GET["filter_name"])) $filter_name = $_GET["filter_name"]; else $filter_name = '';
    if (isset($_GET["filter_tag"])) $filter_tag = $_GET["filter_tag"]; else $filter_tag = '';
    if (isset($_GET["filter_description"])) $filter_description = $_GET["filter_description"]; else $filter_description = '';
    if (isset($_GET["filter_sub_category"])) $filter_sub_category = $_GET["filter_sub_category"]; else $filter_sub_category = '';
    if (isset($_GET["filter_manufacturer_id"])) $filter_manufacturer_id = $_GET["filter_manufacturer_id"]; else $filter_manufacturer_id = '';
    if (isset($_GET["special"])) $special = $_GET["special"]; else $special = '0';
    $this->data['special_block'] = $module = $this->getChild('module/latest', array(
        'special' => $special,
        'limit' => 40,
        'image_width' => 185,
        'category' => $category,

‘start’ => 40*($_GET[“p”]-1),
‘sort’ => $sort,
‘order’ => $order,
‘filter_name’ => $filter_name,
‘filter_tag’ => $filter_tag,
‘filter_description’ => $filter_description,
‘filter_sub_category’ => $filter_sub_category,
‘filter_manufacturer_id’ => $filter_manufacturer_id
));


My intervention made the script to look like this:

    if (isset($_GET["sort"])) $sort = $_GET["sort"]; else $sort = 'p.date_added';
    if (isset($_GET["order"])) $order = $_GET["order"]; else $order = 'DESC';
    if (isset($_GET["category_id"])) $order = $_GET["category_id"]; else $category_id = 0;
    if (isset($_GET["c"])) $category = $_GET["c"]; else $category = 0;
   [b]if(!isset($_GET["p"]) || empty($_GET["p"])){ $_GET["p"] = 0;}[/b]
    if (isset($_GET["filter_name"])) $filter_name = $_GET["filter_name"]; else $filter_name = '';
    if (isset($_GET["filter_tag"])) $filter_tag = $_GET["filter_tag"]; else $filter_tag = '';
    if (isset($_GET["filter_description"])) $filter_description = $_GET["filter_description"]; else $filter_description = '';
    if (isset($_GET["filter_sub_category"])) $filter_sub_category = $_GET["filter_sub_category"]; else $filter_sub_category = '';
    if (isset($_GET["filter_manufacturer_id"])) $filter_manufacturer_id = $_GET["filter_manufacturer_id"]; else $filter_manufacturer_id = '';
    if (isset($_GET["special"])) $special = $_GET["special"]; else $special = '0';
    $this->data['special_block'] = $module = $this->getChild('module/latest', array(
        'special' => $special,
        'limit' => 40,
        'image_width' => 185,
        'category' => $category,
        [b]'start' => 40*($_GET["p"]-1),[/b]
        'sort' => $sort,
        'order' => $order,
        'filter_name' => $filter_name,
        'filter_tag' => $filter_tag,
        'filter_description' => $filter_description,
        'filter_sub_category' => $filter_sub_category,
        'filter_manufacturer_id' => $filter_manufacturer_id

Obviously, i have added the red bold line. Now i have no more PHP notice errors, but i would like to have a qualified opinion (i’m afraid i could have mess something else)…

Thank you

Sponsor our Newsletter | Privacy Policy | Terms of Service