Page 1 of 1

Redirect to new page if there's an MySQL connection error?

Posted: Thu May 22, 2003 8:08 am
by Galt
I have a website that displays a banner on the very top (always), then tries to connect to a MySQL database. I know that if this connection fails, I can't use the header() function to redirect to another page that says something like "sorry, server problems. try again" or something to that effect, since I've already sent data to the client (i.e the banner).

Does anyone have an idea how I can gracefully recover from such a connection error and show another page? Right now I have

Code: Select all

... || die("Can not connect to database");
which to be honest doesn't look professional at all.

Here's what my php code looks like:

< show banner code>
< try to connect to mysql database >
<**would like code here to redirect to new page if conn failed**>
< code to display data retreived from database>

Thanks in advance.

Posted: Thu May 22, 2003 8:19 am
by Galt
Actually, never mind. I think i'll just move the connection code before the banner code. That should fix it.