PHP error redirection query...

I've exhausted other avenues so thought I'd draw on the collective PHP intelligence of the Dolphin forum. I have a busy Dolphin site but also a non-Dolphin site (completely unrelated to dating/social networking etc). Anyway, we have many PHP pages with ID's in the URL - this is all fine and dandy, however, when a non-existant ID is manually entered to the end of the URL a "Warning: Divide by zero etc." status is shown (because the ID does not exist in the database). So, to avoid URL's without an id rendering an actual page (apart from the redirect shown) I have the below code which works for that side of it:

$id=$_GET['id'];
if (!preg_match('/^[0-9]{1,}$/',$id))
header ("Location:index.php");

However, do you have any ideas how to redirect users who decide to go it alone and insert an ID number of their own choosing (that does not exist) which would normally result in the design of the page showing up but also with the "Warning: Divide by zero" string showing?

Bottom line: I need some way to redirect PHP pages that have a non-existant ID. 

Quote · 20 Jun 2011

I guess its the same code .. but now you will tell the php file the following statement " if there is no ID then redirect to the following page " .

eg:

if(!$result){
  header('Location: error.php');
  exit;
}

change the location and the variable.

this should work as i think ..

 

if i did help you .. it wont hurt to go to my profile and add a recommendation for me ;)
Quote · 20 Jun 2011

Thanks for the response - can I add it somehow to the existing code for redirection as shown above?

Oh wait, but there will be ID codes added... yet they might not exist in the database... I need a redirect for cases where they are non-existent in the database. 

Let's say for example: page.php?ID=1 (exists) so that page is correctly shown, however someone types page.php?ID=2 (does not exist as a valid ID) yet it shows a messed up page. I need a redirect for cases where they are non-existent in the database. 

Quote · 20 Jun 2011

could you please attach the file you would like to modify ..

cuz i dont have solphin any where in my pc right now (work)

if i did help you .. it wont hurt to go to my profile and add a recommendation for me ;)
Quote · 20 Jun 2011

This isn't a Dolphin project. The code in question is shown in the first post there and I'm hoping to add/modify that to also redirect for non-existent ID codes, or at least when the body of the page is rendered with the "Warning: Divide by zero" text string. Not sure if this is even possible.

Quote · 20 Jun 2011
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.