jim39 Posted December 28, 2011 Share Posted December 28, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/253972-php-shows-deleted-ids-from-mysql/ Share on other sites More sharing options...
peter_anderson Posted December 28, 2011 Share Posted December 28, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/253972-php-shows-deleted-ids-from-mysql/#findComment-1301952 Share on other sites More sharing options...
The Little Guy Posted December 28, 2011 Share Posted December 28, 2011 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; Quote Link to comment https://forums.phpfreaks.com/topic/253972-php-shows-deleted-ids-from-mysql/#findComment-1301954 Share on other sites More sharing options...
jim39 Posted December 28, 2011 Author Share Posted December 28, 2011 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; Quote Link to comment https://forums.phpfreaks.com/topic/253972-php-shows-deleted-ids-from-mysql/#findComment-1301975 Share on other sites More sharing options...
kicken Posted December 28, 2011 Share Posted December 28, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/253972-php-shows-deleted-ids-from-mysql/#findComment-1301977 Share on other sites More sharing options...
jim39 Posted December 28, 2011 Author Share Posted December 28, 2011 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"> Quote Link to comment https://forums.phpfreaks.com/topic/253972-php-shows-deleted-ids-from-mysql/#findComment-1301985 Share on other sites More sharing options...
The Little Guy Posted December 28, 2011 Share Posted December 28, 2011 include "config.php"; $sorgu = "select * from table where id=$id"; $sonuc = mysql_query($sorgu) or die(mysql_error()); if(mysql_num_rows($sonuc) == 0){ header("HTTP/1.0 404 Not Found"); header("Status: 404 Not Found"); readfile("/errors/404.html"); exit; } $baslik1 = mysql_fetch_row($sonuc); Quote Link to comment https://forums.phpfreaks.com/topic/253972-php-shows-deleted-ids-from-mysql/#findComment-1302009 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.