PHP Website Offline

diabolo

Community Advocate
Community Support
Messages
1,682
Reaction score
32
Points
48
Code:
[PHP]<?php
require('config.php');

if($maintenance_mode == "1"){
  include('maintenance.php');
  exit();
} else {
  if($construction_mode == "1"){
    include('construction.php');
    exit();
  } else {
?>[/PHP]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
  <title>trial1 - anasianscreations</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link rel="stylesheet" type="text/css" href="style.css" media="screen"/>
</head>
<body>
<!--ContentHere-->
</body>
</html>

[PHP]<?php
  }
}
?>[/PHP]


I want to have this part in a file called: 'check.php'
PHP:
<?php
require('config.php');

if($maintenance_mode == "1"){
  include('maintenance.php');
  exit();
} else {
  if($construction_mode == "1"){
    include('construction.php');
    exit();
  } else {
?>
but when I do an include, it gives me an error that an unexpected end, since I thinks I didn't finish the end brackets; what can I do to fix this?
 

diabolo

Community Advocate
Community Support
Messages
1,682
Reaction score
32
Points
48
the code basically goes like this:

look into config.php if $variable_1 is 1, then include link1 and exit page; else look for $variable_2 if 1, then include link2 and exit page, else display the rest of the contents on that page(HTML)

at the end I end the brackets }}
 

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
So you gonna do like:

PHP:
<?php
require('config.php');

if($maintenance_mode == "1"){
  include('maintenance.php');
  exit();
} else {
  if($construction_mode == "1"){
    include('construction.php');
    exit();
  } else {
?>
html code
<?php }} ?>
?

I suggest this:

PHP:
<?php
require('config.php');

if($maintenance_mode == "1"){
  include('maintenance.php');
  exit();
} elseif($construction_mode == "1") {
    include('construction.php');
    exit();
  } else {
?>
html code
<?php } ?>
 
Last edited:

diabolo

Community Advocate
Community Support
Messages
1,682
Reaction score
32
Points
48
yeah like that but I want to place the PHP code is a seperate file(check.php, check_end.php) so if I change them I don't have to manually do everypage

but when I tried that it ended up in an unexpected END error
 

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
yeah like that but I want to place the PHP code is a seperate file(check.php, check_end.php) so if I change them I don't have to manually do everypage

but when I tried that it ended up in an unexpected END error

Did you try the code I suggested?
 

diabolo

Community Advocate
Community Support
Messages
1,682
Reaction score
32
Points
48
I tried what you suggested, it works when I hardcode it in, but I also tried it using:
Code:
<?php include('check.php');?>
<html>
<?php include('check_end.php'); ?>
and that came up with
Code:
Parse error: syntax error, unexpected $end in C:\xampp\htdocs\aac\check.php on line 11
 

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
I tried what you suggested, it works when I hardcode it in, but I also tried it using:
Code:
<?php include('check.php');?>
<html>
<?php include('check_end.php'); ?>
and that came up with
Code:
Parse error: syntax error, unexpected $end in C:\xampp\htdocs\aac\check.php on line 11

Could you post line 11 please?
 

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
hmmmm, try deleting the php tags from the files included.

Because wouldn't

<?php
include('somefile.php');
?>

become:

<?php
<?php
Content of somefile.php
?>
?>

?
 

diabolo

Community Advocate
Community Support
Messages
1,682
Reaction score
32
Points
48
I did that and it shows the html, and displays the php

so I guess I keep the <?php ?>
 

diabolo

Community Advocate
Community Support
Messages
1,682
Reaction score
32
Points
48
I think i found my fix: I got rid of the check_end

and
PHP:
<?php
require('config.php');

if($maintenance_mode == "1"){
  include('maintenance.php');
  exit();
} elseif($construction_mode == "1") {
    include('construction.php');
    exit();
  } else { }
?>

just added the bracket into the opening
 
Top