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 8112557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:32:40+00:00 2026-06-06T02:32:40+00:00

I’m querying the database for a single record that matches the id passed in

  • 0

I’m querying the database for a single record that matches the id passed in a url segment www.site.com/post/24.

Suppose post 24 doesn’t exist. What is a safe and seo compliant way to deal with database requests that aren’t found?

Below is my current solution using a Codeigniter model:

    function read_post($post_id) //argument is the value of the url segment
    {
        $user_id = $this->tank_auth->get_user_id();

        $this->db->where('user_id', $user_id);
        $this->db->where('post_id', $post_id);
        $this->db->limit(1);
        $query = $this->db->get('posts');

        //check if record exists
        if ($query->num_rows() > 0) //row is returned
        {
            return $query->row(); //passed to controller and view
        }
        else
        {
            show_404(); //generate 404 message
            return FALSE; //------------------------or exit()?
        }
    }

Please share your own best method/opinions.

  • 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-06-06T02:32:41+00:00Added an answer on June 6, 2026 at 2:32 am

    Show a 404 page (with the 404 HTTP status code). That’s the correct way of doing it. Otherwise you will just pretend you have infinitely many pages without content.

    Describe shortly on the 404 page that the content isn’t there anymore. Then you may add links to other popular content on your web page. For the sake of the user it’s encouraged to try to lead them forward from the 404 page to interesting content, but do this with links so the user can read the 404 message and choose what to do next.

    If you have meaningful URLs with words in you may also extract the words and do some kind of search in your database. List the search results on the 404 page as well, under some heading like “You may be interested in…”. If you are selling a product or service, don’t hesitate to make the 404 page into a nice selling one!

    I have a strong belief in that the best SEO is the one which is best for your visitors. It’s all about keeping them on your web site, and not scaring them away. Make your web site as user-friendly as possible and make it easy to find all your interesting content. My answer above stems directly from that belief. Do The Right Thing according to the standards (the HTTP standard in this case) and at the same time try to catch the user with good content and services. This is most certainly also what’s best for your company at large regarding sales.

    • 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 an if statement in PHP that prevents a single post
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
Specifically, suppose I start with the string string =hello \'i am \' me And
I am doing a simple coin flipping experiment for class that involves flipping a
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.