1

So far this is what I have, but it doesn't seem to be working...

    <?
    $file = fopen('wiu.dat','r')
    while (wui = fgets($file)){
    if ($wui = 'True') {
      header("Location: index.html");
      die()
    } else {
      echo"<h2>Down for maintenance.</h2>"
    ;}}
    fclose($fh);
    ?>

Any feedback would be greatly appreciated

4
  • What is the content of the wiu.dat file? Also edit the if ($wui == 'True') statement. Commented Oct 9, 2015 at 1:18
  • Pretty sure you want to fclose before you die(), I could be wrong though. Commented Oct 9, 2015 at 1:22
  • 1
    missing a $ in while (wui for one thing. If that's your actual code, error reporting's saying "undefined constant wui...". Commented Oct 9, 2015 at 1:30
  • @C1sc0 it will either be true or false Commented Oct 9, 2015 at 1:32

1 Answer 1

3

I fixed the obvious problems. I added a semicolon after your first line and after die(), changed wui to $wui in your while condition, changed $wui = 'True' to $wui == 'True', changed fclose($fh); to fclose($file); and cleaned up your indentation just so it looks nicer. From there, I guess the success of the code depends on what you've got inside wiu.dat.

<?php
  $file = fopen('wiu.dat','r');
  while ($wui = fgets($file)) {
    if ($wui == 'True') {
      header("Location: index.html");
      die();
    } else {
      echo"<h2>Down for maintenance.</h2>";
    }
  }
  fclose($file);
?>
Sign up to request clarification or add additional context in comments.

3 Comments

Can't believe I missed all that, OP do you have error reporting turned off? These are all things a single test run should tell you!
@Glubus I'm new to web developement I didnt even think to open the console
In what environment are you coding then? You don't really use a console when you're programming php. Whenever you load the page it'll parse the error as html, unless you have your error reporting turned off, which you should not have.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.