Connection problems and other notises and SSI

Started by Owdy, May 16, 2005, 10:32:20 AM

Previous topic - Next topic

Owdy

When forum (mysql) goes down, i get white page with warning text. But in main site where i use SSI, that just brokes that page with random php warnings. Quoestion, how can i make my main site use that same error page as forum does? Can i make custom one?
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

rakuli

PHP Error Handling

You can look at adding some error handling functions to your SSI.php or on the page in question. There's tonnes of things you can do with errors. Or you can just turn them off.

error_reporting(0);

Owdy

Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

rakuli

You can add it to the script. You don't need to touch the php.ini.

For example you could just go

<?php require('ssi.php'); error_reporting(0); ?>
<html>
.....your page
</html>



Owdy

Hmm,okay. How do i ad it in my main site? Do i make some error.php page or ad that code in my current page? I want it to show only that when fatal error appears.
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

Owdy

#5
I use this:

<?php
;
$ssi_ban true;
ob_start();
require(
"/www/asiakkaat/hoitajat/public_html/foorumi/SSI.php"); if (!$db_connection || !@mysql_select_db($db_name$db_connection))
db_fatal_error();
if (
$maintenance == 2)
db_fatal_error();
 
?>


It gives correct error notice but with error:

QuoteWarning: mysql_error(): supplied argument is not a valid MySQL-Link resource in /www/asiakkaat/hoitajat/public_html/foorumi/Sources/Subs-Auth.php on line 311

How do i adjust it?

Or better, how can i make my own message?
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

rakuli

In your SSI.php you could do something like this for a failed connection to the database.

FInd




// Connect to the MySQL database.
if (empty($db_persist))
	
$db_connection = @mysql_connect($db_server$db_user$db_passwd);
else
	
$db_connection = @mysql_pconnect($db_server$db_user$db_passwd);
if (
$db_connection === false)
	
return 
false;


Change to


// Connect to the MySQL database.
if (empty($db_persist)){
	
$db_connection = @mysql_connect($db_server$db_user$db_passwd);
                if (!
$db_connection){
                echo     
"Unfortunately we are unable to connect to the database at this time. Please try again later";
                     exit();

                }
    }
else{
	
$db_connection = @mysql_pconnect($db_server$db_user$db_passwd);
              if (!
$db_connection){
                echo     
"Unfortunately we are unable to connect to the database at this time. Please try again later";
                     exit();
           }
}
if (
$db_connection === false)
	
return 
false;


Owdy

Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

[Unknown]

Doesn't it already return false when you have problems?

You could do:

$ssi = include('SSI.php');

if (!$ssi)
   die;

-[Unknown]

Owdy

Quote from: [Unknown] on May 16, 2005, 01:18:53 PM
Doesn't it already return false when you have problems?

With basic SSI i get fatal erros, see attacment.

If i use this in top of my page <?php
$ssi_gzip 
true;
$ssi_ban true;
ob_start();
require(
"/www/asiakkaat/public_html/foorumi/SSI.php"); 

if (!
$db_connection || !@mysql_select_db($db_name$db_connection))
db_fatal_error();

if (
$maintenance == 2)
db_fatal_error();
?>
, i get this:

QuoteWarning: mysql_error(): supplied argument is not a valid MySQL-Link resource in /www/asiakkaat/public_html/foorumi/Sources/Subs-Auth.php on line 311
Connection Problems
Sorry, SMF was unable to connect to the database. This may be caused by the server being busy. Please try again later.

Quote from: [Unknown] on May 16, 2005, 01:18:53 PM

You could do:

$ssi = include('SSI.php');

if (!$ssi)
   die;

Thanks, i try that.
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

[Unknown]

You're not going to have template_menu if SMF died.

-[Unknown]

Owdy

Tryed this, got blank page

Quote<?php
$ssi_gzip = true;
$ssi_ban = true;

$ssi = include('/www/asiakkaat/hoitajat/public_html/foorumi/SSI.php');

if (!$ssi)
   die;
ob_start();
?>
I dont want blank page, i want to show  message :)
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

[Unknown]

So, instead of die;, use:

{
   echo 'Ding, dong, the server\'s dead... the server\'s dead.... please come back later.';
   die;
}

-[Unknown]

Owdy

#13
LOL, okay :D

edit: this is perfect solution. Thanks !!  :)


<?php
$ssi_gzip 
true;
$ssi_ban true;
ob_start();
$ssi = include('/www/asiakkaat//public_html/foorumi/SSI.php');

if (!
$ssi)
   {
   echo 
'Serverillä näyttää olevan ongelmia. Ole hyvä ja yritä myöhemmin uudelleen.';
   die;
}
?>

Does that code look okay to you? Im not eaven sure what that ob_start(); is.  :D
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

Advertisement: