mme Posted December 13, 2007 Share Posted December 13, 2007 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' ) ;}} ?> Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted December 13, 2007 Share Posted December 13, 2007 Your arguments aren't wrapped in parenthesis () for your if statements. Quote Link to comment Share on other sites More sharing options...
xProteuSx Posted December 13, 2007 Share Posted December 13, 2007 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' ) ;} } ?> Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted December 13, 2007 Share Posted December 13, 2007 Also, you need to use the double "==" for comparison, not the single "=". Ken Quote Link to comment Share on other sites More sharing options...
mme Posted December 14, 2007 Author Share Posted December 14, 2007 Thanks the code seems to be working however when the variables are all set to false it just shows a blank page instead of the specified html page. Quote Link to comment Share on other sites More sharing options...
[-razer-]Blade Posted December 14, 2007 Share Posted December 14, 2007 <?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. Quote Link to comment Share on other sites More sharing options...
derrick24 Posted December 14, 2007 Share Posted December 14, 2007 I don't think that will work. You telling the code to exit here: if ($disable = "true") {printf("The Website you are trying to reach is currently unavailible"); exit;} so nothing after that will execute. Quote Link to comment Share on other sites More sharing options...
derrick24 Posted December 14, 2007 Share Posted December 14, 2007 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'); } ?> Quote Link to comment Share on other sites More sharing options...
~n[EO]n~ Posted December 14, 2007 Share Posted December 14, 2007 See the difference $disable AND $disbale Quote Link to comment Share on other sites More sharing options...
derrick24 Posted December 14, 2007 Share Posted December 14, 2007 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; } ?> Quote Link to comment Share on other sites More sharing options...
mme Posted December 14, 2007 Author Share Posted December 14, 2007 Thanks Works perfectly Quote Link to comment Share on other sites More sharing options...
mme Posted December 14, 2007 Author Share Posted December 14, 2007 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? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted December 14, 2007 Share Posted December 14, 2007 You would need to put a "default" case into your switch statment. Ken Quote Link to comment Share on other sites More sharing options...
mme Posted December 14, 2007 Author Share Posted December 14, 2007 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 Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 14, 2007 Share Posted December 14, 2007 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. Quote Link to comment Share on other sites More sharing options...
mme Posted December 14, 2007 Author Share Posted December 14, 2007 Thanks solved Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.