Jump to content

php shows deleted ids from mysql


jim39

Recommended Posts

Hi

 

I have deleted quite lot data from mysql database however,  php still shows that page but blank ie page.php?id=186  - this id and all assosiated fields with this id has been removed from mysql but id still showing on the net and google cached all of them ( 600 pages) . page.php is still in use but I was wondering if there is any way not to show these blank pages/ids from mysql db and more importantly how can I remove these blank pages from google?

 

Thanks for your help.

 

Link to comment
Share on other sites

If there are no results, give a 404 header:

header("HTTP/1.0 404 Not Found");

 

Google will eventually remove it from their DB. You'll also want to give a message saying it wasn't found.

 

That wont always work, when you throw an error page, you should do it like so:

 

header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found");

 

you will also want to make a custom 404 page, and in that case you would do this:

 

// If the file is not found run this:
header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found");
readfile("/errors/404.html");
exit;

Link to comment
Share on other sites

Thank you! but page.php is still in use so when we add

header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found");

we are automaticly redirecting all pages regardless of empty or not.

 

I am looking for more if the page empty do 404 if not display the whatever information comes from mysql db?

 

does this make sense?

 

Thanks

 

 

 

If there are no results, give a 404 header:

header("HTTP/1.0 404 Not Found");

 

Google will eventually remove it from their DB. You'll also want to give a message saying it wasn't found.

 

That wont always work, when you throw an error page, you should do it like so:

 

header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found");

 

you will also want to make a custom 404 page, and in that case you would do this:

 

// If the file is not found run this:
header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found");
readfile("/errors/404.html");
exit;

Link to comment
Share on other sites

I am looking for more if the page empty do 404 if not display the whatever information comes from mysql db?

 

That's what you were told to do.  At some point in your page you're running a query to fetch the information.  If that query returns 0 rows, then (and only then) do you output those 404 headers.  If the query does find data, you just continue on normally.

 

Link to comment
Share on other sites

That's what you were told to do.  At some point in your page you're running a query to fetch the information.  If that query returns 0 rows, then (and only then) do you output those 404 headers.  If the query does find data, you just continue on normally.

 

Thanks. I can't get this work  - when I place

header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found");

it just shows all pages 404.

 

here is my code without

header("HTTP/1.0 404 Not Found");

 

<?php
$id	=	(int)$_GET['id'];
if(isset($id))
{
  include "config.php";
  $sorgu = "select * from table where id=$id";
  $sonuc = mysql_query($sorgu)
  or die(mysql_error());
  $baslik1 = mysql_fetch_row($sonuc);
?>
<?php
#sorgula
$sorgu = "select * from table";
$sonuc = mysql_query($sorgu)
or die(mysql_error());
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

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.