Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

If connection to data base fails redirect to other page


Guest

Recommended Posts

Posted

Yesterday my data base server went down.

When I tried to access my web page as a customer I got an error page which showed the path to my database.php

 

If this happens I would like to redirect customers to a custom error page for example error_page.html

 

I have searched the forums and came a step closer to a fix but not all the way:

 

In includes/application_top.php

 

I replaced:

tep_db_connect() or die('Unable to connect to database server!');

 

With:

tep_db_connect() or tep_redirect('http://www.mysite.com/error_page.html');

 

Unfortunally this didn?t work and gave me the following error:

Fatal error: Call to undefined function: tep_redirect() in.....path to my application_top.php

 

Does anybody have a solution for this?

 

Thanks in advance.

 

/Per

Posted
tep_db_connect() or header('Location:http://www.mysite.com/error_page.html');

 

Thanks for your reply.

I just tried it and it doesn?t work. It gave me all sorts of errors.

One of the errors was this one:

Warning: Cannot modify header information - headers already sent by (output started at....path to my database.php

 

Anything else I can try?

  • 11 months later...
Posted

open includes/functions/database.php

 

Change this:

 

if (USE_PCONNECT == 'true') {

$$link = mysql_pconnect($server, $username, $password);

} else {

$$link = mysql_connect($server, $username, $password);

}

 

to this:

 

if (USE_PCONNECT == 'true') {

$$link = mysql_pconnect($server, $username, $password);

if ($$link == 0) {

header('Location: error_page.html'); // and you want print error or anything else

}

} else {

$$link = mysql_connect($server, $username, $password);

if ($$link == 0) {

header('Location: error_page.html'); // and you want print error or anything else

}

 

}

Archived

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

×
×
  • Create New...