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' ) ;}} ?> Link to comment https://forums.phpfreaks.com/topic/81577-solved-whats-wrong-this-code/ 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. Link to comment https://forums.phpfreaks.com/topic/81577-solved-whats-wrong-this-code/#findComment-414263 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' ) ;} } ?> Link to comment https://forums.phpfreaks.com/topic/81577-solved-whats-wrong-this-code/#findComment-414272 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 Link to comment https://forums.phpfreaks.com/topic/81577-solved-whats-wrong-this-code/#findComment-414278 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. Link to comment https://forums.phpfreaks.com/topic/81577-solved-whats-wrong-this-code/#findComment-414697 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. Link to comment https://forums.phpfreaks.com/topic/81577-solved-whats-wrong-this-code/#findComment-414741 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. Link to comment https://forums.phpfreaks.com/topic/81577-solved-whats-wrong-this-code/#findComment-414749 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'); } ?> Link to comment https://forums.phpfreaks.com/topic/81577-solved-whats-wrong-this-code/#findComment-414761 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 Link to comment https://forums.phpfreaks.com/topic/81577-solved-whats-wrong-this-code/#findComment-414762 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; } ?> Link to comment https://forums.phpfreaks.com/topic/81577-solved-whats-wrong-this-code/#findComment-414764 Share on other sites More sharing options...
mme Posted December 14, 2007 Author Share Posted December 14, 2007 Thanks Works perfectly Link to comment https://forums.phpfreaks.com/topic/81577-solved-whats-wrong-this-code/#findComment-415025 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? Link to comment https://forums.phpfreaks.com/topic/81577-solved-whats-wrong-this-code/#findComment-415043 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 Link to comment https://forums.phpfreaks.com/topic/81577-solved-whats-wrong-this-code/#findComment-415047 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 Link to comment https://forums.phpfreaks.com/topic/81577-solved-whats-wrong-this-code/#findComment-415111 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. Link to comment https://forums.phpfreaks.com/topic/81577-solved-whats-wrong-this-code/#findComment-415117 Share on other sites More sharing options...
mme Posted December 14, 2007 Author Share Posted December 14, 2007 Thanks solved Link to comment https://forums.phpfreaks.com/topic/81577-solved-whats-wrong-this-code/#findComment-415176 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.