Jump to content

[SOLVED] Whats wrong this code


mme

Recommended Posts

Whats wrong with this code I get the error:

Parse error: syntax error, unexpected T_VARIABLE, expecting '(' in /home/mamihoo/public_html/test/check.php on line 3

 

<?php
include("settings.php");
if $disable = "true" {printf("The Website you are trying to reach is currently unavailible"); exit;}
if $update = "true" {printf("The Website you are trying to reach is currently being updated"); exit;}
if $disbale = "false"
{
if $update = "false" {
header( 'Location: pass.html' ) ;}}
?>

Link to comment
https://forums.phpfreaks.com/topic/81577-solved-whats-wrong-this-code/
Share on other sites

As wildteen88 said, try this:

 

<?php

include("settings.php");

if ($disable = "true")

  {printf("The Website you are trying to reach is currently unavailible"); exit;}

if ($update = "true")

  {printf("The Website you are trying to reach is currently being updated"); exit;}

if ($disbale = "false")

  {

  if ($update = "false")

      {header( 'Location: pass.html' ) ;}

  }

?>

<?php

include("settings.php");

if ($disable = "true") {printf("The Website you are trying to reach is currently unavailible"); exit;}

if ($update = "true") {printf("The Website you are trying to reach is currently being updated"); exit;}

if ($disbale = "false")

  {

  elseif ($update = "false")

      {header( 'Location: pass.html' ) ;}

  }

?>

 

Try this. I'm still kinda new to php but I think that might work. ;D

Ignore my last comment, try this.

 

<?php
//include("settings.php");
$update = false;
$disable = false;
if ($update == "true") {printf("The Website you are trying to reach is currently being updated"); exit;}
if ($disable == "true") 
{
printf("The Website you are trying to reach is currently unavailible"); exit;
}
else
{
header('Location: pass.html');
}
?>

I do now, I would try use something similar to this method:

 

<?php
//include("settings.php");
// $status can be ready, updating or disabled
$status = "ready";
switch($status)
{
// View Website
case "ready" :
header('Location: pass.html');
break;

// Website is been updated
case "updating" :
print "This website is being updated.";
break;

// Website is disabled
case "disabled" :
print "This website is disabled.";
break;
}
?>

Sorry I just thought of something. what if the variable status is something that is not in the switch statment command how can I make it display a something instead of a blank page?

 

eg;

 

status = "hhfiudh"

 

currently it displays a blank page

how would I make it display something?

Ok thanks however now when i went to put my html code around the php codes so it displays in a certain part of the page it gave me the error

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/mysite/httpdocs/index.php:21) in /var/www/vhosts/mysite/httpdocs/index.php on line 72

Ok thanks however now when i went to put my html code around the php codes so it displays in a certain part of the page it gave me the error

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/mysite/httpdocs/index.php:21) in /var/www/vhosts/mysite/httpdocs/index.php on line 72

 

The header function must be called before any HTML on the page.

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.