Jump to content

[SOLVED] custom error handler problem


petersro

Recommended Posts

i have an confusing problem

 

here is the code

 

sys_error

<?php

/**
* @author 
* @copyright 2008
*/
if(isset($_GET['error=conn_error'])):
    echo "Im sorry the system could not connect to the database server";
elseif(isset($_GET['error=conn_error'])):
    echo "Im sorry there is a problem with the database";
else:
    echo "An unknown error has occured";
endif;
?>

 

sys_mysql.php

<?php
/**
* @author 
* @copyright 2008
*/

//System loading what we need
require ('sys_config.php');

//Starting Connections
$conn = mysql_connect($db_host,$db_user,$db_pass);   
if(!$conn)
{
header("Location:sys_error.php?error=conn_error");
}
$db = mysql_select_db(db_name,$conn);
if(!$db)
{
header("Location:sys_error.php?error=db_error");
}
?>

 

the result is

an unknown error occured

 

i know for a fact that the password i have placed for de-bugging purposes is wrong, so it should result in cant connect to  db server

Link to comment
https://forums.phpfreaks.com/topic/136140-solved-custom-error-handler-problem/
Share on other sites

<?php

/**
* @author 
* @copyright 2008
*/
if($_GET['error'] == 'conn_error'):
    echo "Im sorry the system could not connect to the database server";
elseif($_GET['error'] == 'db_error'):
    echo "Im sorry there is a problem with the database";
else:
    echo "An unknown error has occured";
endif;
?>

Yes you can, you can do whatever you want with it

 

<?php

/**
* @author 
* @copyright 2008
*/
if($_GET['error'] == 'conn_error'):
    $error = "Im sorry the system could not connect to the database server";
elseif($_GET['error'] == 'db_error'):
    $error = "Im sorry there is a problem with the database";
else:
    $error = "An unknown error has occured";
endif;
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.