Jump to content

PHP die function


scferg

Recommended Posts

Hmmm...just noticed something. The ?section=BLAH&page=BLAH.php function doesn't work. If you visit my site, hover over the down arrow on the nav, then click News Archives, it goes to the 404 error page. It worked before, I don't know what's wrong...

Link to comment
Share on other sites

There is two reasons for that

 

1) There is a period in the name of the page, which violates our letters/spaces/underscores requirement

2) The script automatically adds .html to the end of it. So even if it got past #1, it would be looking for the page:

news/show_archives.php.html

 

Does the show_archives.php file have to be a .php? or can it be .html?

 

Link to comment
Share on other sites

my recommendation is to do the follow:

 

Step 1) Make all your .html files .php instead

 

Step 2) Change the script to:

<?php
  $error_page = "./404.php";
  $page = $_GET['page'];
  $section = $_GET['section'];

  if($page == "case1") { //Handle special cases first
    echo "case1 goes here no page was written for this statement.";
  } elseif($page) { //Page requested
    $path = "{$page}.php";
    if($section) //Add section
      $path = "{$section}/{$path}";
    //Check keys and existance
    if( preg_match('/^\w+$/',$page) && 
        (!strlen($section) || preg_match('/^\w+$/',$section)) && 
        file_exists($path)
      )
      include($path); //Good to go...include it
    else
      include($error_page); //Error page
  } else { //Default
    $number=10;
    $only_active=TRUE;
    include("./news/show_news.php");
  }
?>

 

Step 3) Have the URL for the News Archive be like the others: http://sims2news.com/?section=news&page=show_archives

Link to comment
Share on other sites

Ok, I changed my mind...I changed the code and switched the files to .php . It works great now!

 

This is kind of off topic, but just out of curiosity...on my 404.php page, is there a way to display the page requested that has not been found?

 

Like: The page http://sims2news.com/?page=1234 has not been found

 

It's not necessary, but it would be cool if it could

 

Thanks!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.