I have this problem ERR_TOO_MANY_REDIRECTS on localhost, the script it runs perfectly on the server. I am using Wampserver 3.0 and PHP version 7.0. Here is the script:
require_once('header.php');
// Preventing the direct access of this page.
if(!isset($_REQUEST['slug']))
{
header('location: index.php');
exit();
}
else
{
// Check the category slug is valid or not.
$statement = $pdo->prepare("SELECT * FROM tbl_category WHERE category_slug=? AND status=?");
$statement->execute(array($_REQUEST['slug'],'Active'));
$total = $statement->rowCount();
if( $total == 0 )
{
header('location: index.php');
exit();
}
}
// Getting the category name from the category slug
$statement = $pdo->prepare("SELECT * FROM tbl_category WHERE category_slug=?");
$statement->execute(array($_REQUEST['slug']));
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row)
{
$category_name = $row['category_name'];
$category_id = $row['category_id'];
}
$statement = $pdo->prepare("SELECT * FROM tbl_news_category WHERE
category_id=? AND access=1");
$statement->execute(array($category_id));
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row)
{
$news_id_arr[] = $row['news_id'];
}