Advertisement:

Author Topic: Connection problems and other notises and SSI  (Read 6349 times)

Offline Owdy

  • SMF Fossil
  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 15,627
  • Gender: Male
  • W00t!
    • janoloferiksson on LinkedIn
    • @@jaoler on Twitter
Connection problems and other notises and SSI
« on: May 16, 2005, 10:32:20 AM »
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?
« Last Edit: May 16, 2005, 10:34:10 AM by 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

Offline rakuli

  • Jr. Member
  • **
  • Posts: 325
  • Gender: Male
    • Turn over a playful leaf on web design
Re: Connection problems and other notises and SSI
« Reply #1 on: May 16, 2005, 10:59:15 AM »
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.

Code: [Select]
error_reporting(0);

Offline Owdy

  • SMF Fossil
  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 15,627
  • Gender: Male
  • W00t!
    • janoloferiksson on LinkedIn
    • @@jaoler on Twitter
Re: Connection problems and other notises and SSI
« Reply #2 on: May 16, 2005, 11:24:33 AM »
I am not my own host. I cant edit php.ini.
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

Offline rakuli

  • Jr. Member
  • **
  • Posts: 325
  • Gender: Male
    • Turn over a playful leaf on web design
Re: Connection problems and other notises and SSI
« Reply #3 on: May 16, 2005, 11:27:58 AM »
You can add it to the script. You don't need to touch the php.ini.

For example you could just go

Code: [Select]
<?php require(&#39;ssi.php&#39;); error_reporting(0); ?>
<html>
.....your page
</html>


Offline Owdy

  • SMF Fossil
  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 15,627
  • Gender: Male
  • W00t!
    • janoloferiksson on LinkedIn
    • @@jaoler on Twitter
Re: Connection problems and other notises and SSI
« Reply #4 on: May 16, 2005, 11:37:07 AM »
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

Offline Owdy

  • SMF Fossil
  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 15,627
  • Gender: Male
  • W00t!
    • janoloferiksson on LinkedIn
    • @@jaoler on Twitter
Re: Connection problems and other notises and SSI
« Reply #5 on: May 16, 2005, 11:49:57 AM »
I use this:

Code: [Select]
<?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:

Quote
Warning: 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?
« Last Edit: May 16, 2005, 12:02:50 PM by 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

Offline rakuli

  • Jr. Member
  • **
  • Posts: 325
  • Gender: Male
    • Turn over a playful leaf on web design
Re: Connection problems and other notises and SSI
« Reply #6 on: May 16, 2005, 12:12:44 PM »
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;


Offline Owdy

  • SMF Fossil
  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 15,627
  • Gender: Male
  • W00t!
    • janoloferiksson on LinkedIn
    • @@jaoler on Twitter
Re: Connection problems and other notises and SSI
« Reply #7 on: May 16, 2005, 12:24:08 PM »
No, i dont want hack SSI.php :)
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

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Connection problems and other notises and SSI
« Reply #8 on: May 16, 2005, 01:18:53 PM »
Doesn't it already return false when you have problems?

You could do:

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

if (!$ssi)
   die;

-[Unknown]

Offline Owdy

  • SMF Fossil
  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 15,627
  • Gender: Male
  • W00t!
    • janoloferiksson on LinkedIn
    • @@jaoler on Twitter
Re: Connection problems and other notises and SSI
« Reply #9 on: May 16, 2005, 01:25:20 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
Code: [Select]
<?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:

Quote
Warning: 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.


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

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Connection problems and other notises and SSI
« Reply #10 on: May 16, 2005, 01:27:00 PM »
You're not going to have template_menu if SMF died.

-[Unknown]

Offline Owdy

  • SMF Fossil
  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 15,627
  • Gender: Male
  • W00t!
    • janoloferiksson on LinkedIn
    • @@jaoler on Twitter
Re: Connection problems and other notises and SSI
« Reply #11 on: May 16, 2005, 01:31:47 PM »
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

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Connection problems and other notises and SSI
« Reply #12 on: May 16, 2005, 01:33:04 PM »
So, instead of die;, use:

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

-[Unknown]

Offline Owdy

  • SMF Fossil
  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 15,627
  • Gender: Male
  • W00t!
    • janoloferiksson on LinkedIn
    • @@jaoler on Twitter
Re: Connection problems and other notises and SSI
« Reply #13 on: May 16, 2005, 01:49:55 PM »
LOL, okay :D

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

Code: [Select]
<?php
$ssi_gzip 
true;
$ssi_ban true;
ob_start();
$ssi = include(&#39;/www/asiakkaat//public_html/foorumi/SSI.php&#39;);

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

Does that code look okay to you? Im not eaven sure what that ob_start(); is.  :D
« Last Edit: May 16, 2005, 03:42:35 PM by 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