Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6536197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:27:43+00:00 2026-05-25T10:27:43+00:00

I am trying to create an error page but I want to specify it

  • 0

I am trying to create an error page but I want to specify it on a certain dictionary.
the problem is that it is a php file.
for example if I have a page with a title called page1 only and do not have anything else, I want to display an error for every other page that does not exist like page2.
http://example.com/showpage.php?title=page1
http://example.com/showpage.php?title=page2
I do not want to use htaccess because there is other files in the same dictionary that I want to display another error message.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:27:49+00:00Added an answer on May 25, 2026 at 10:27 am

    Do you query against a database or do you include real files like page1.php for example?

    EDIT:
    If you are using MySQL, then you want to use mysql_num_rows() against your query and if that returns true, do all the echoing, but if it returns false, then include_once(‘error-for-non-existing-title.php’); Optionally if no $title variable is set, you could throw a 404 header. You can rewrite your 404 documents in .htaccess if you want to

    I think for an online-reader, you should have more than one variable ($_GET[‘title’]) AND $_GET[‘page’]. Use $title to differentiate between different titles and $page to navigate through it’s pages.

    I guess you don’t know how to use PDO yet, so..

    $link = mysql_connect("localhost", "username", "password");
    mysql_select_db("database_name", $link);
    
    if(isset($_GET['title']))  {
    $title = $_GET['title'];
    
    $query = mysql_query("SELECT * FROM pages WHERE title='$title'", $link);
    
    $num_rows = mysql_num_rows($query);
    
    //if there is a page
    if($num_rows!=0) {
    
    //fetch the data as associative array
    $result = mysql_fetch_assoc($query);
    
    echo $result['title'],'<br />';
    }
    else include_once('error.php');
    }
    
    //optionally if you want to, you could throw a 404 header if there is no $title
    //variable set. Just remove the double slashes from the next line of code.
    //else header("HTTP/1.1 404 Not Found");  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a php page with fopen() this php file will house
I'm trying to submit a php form to a database, but I want that
I want to create a Delicious bookmarklet in Firefox that bookmarks the current page
I'm trying to create a PHP backend that is flexible enough so it doesn't
I'm trying to create a login and logout page with django. The problem I
In order to trace some performance issues, I'm trying to create a page that
I'm trying to create a box on the side of a page that displays
I am currently trying to create a multi-page form that uses both jQuery and
I'm trying to create my own error window for the project I am working
Trying to create a background-image slideshow and am getting this error... This is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.