#1
  1. No Profile Picture
    riddler
    Guest
    Devshed Newbie (0 - 499 posts)
    Riddle me this:

    What exactly does it mean when your PHP script results in a "Document Contains No Data" message? It only happens from time to time for a given script, which I find especially strange. If it were consistent, I would assume that there was a logical error in the script, but it works perfectly 85% of the time!

    So what is "Document Contains No Data"?
    What causes it?
  2. #2
  3. No Profile Picture
    rod k
    Guest
    Devshed Newbie (0 - 499 posts)
    That is a error reported by the client. It means that for whatever reason the server did not send any data. Why this happened may or may not have anything to do with your script. I'd have to look at the code to figure out where the problem might be.
  4. #3
  5. No Profile Picture
    riddler
    Guest
    Devshed Newbie (0 - 499 posts)
    Well, the script is several hundred lines long, so I won't bog down this board with that.

    My hunch is that there is nothing wrong with the logic of the PHP code. It's pretty straightfoward, I've been over it a thousand times, and the script usually works fine.

    If we momentarily assume that there is nothing wrong with the code, what other factors might lead to the message from the browser? Something wrong with Apache? With the configuration of PHP? With Linux? With MySQL?
  6. #4
  7. No Profile Picture
    rod k
    Guest
    Devshed Newbie (0 - 499 posts)
    If it happens with other scripts then it's a lower level problem (e.g. apache or linux).

    If it's only this script, chances are it's a problem with the script. Possibly the script is exiting before sending any data due to a logical problem. It shouldn't be a mysql error or a parse error or anything else that php would send an error message for as you would get. Oh, there's a thought, what's your error supression set at? I don't know if it's possible to suppress fatal errors, but if it is and you have then a fatal error could produce that as the script would stop executing but no message would be sent.
  8. #5
  9. No Profile Picture
    riddler
    Guest
    Devshed Newbie (0 - 499 posts)
    Well, I've narrowed down the problem. I've defined a class called Doc. I've discovered that if I comment out any attempt to instantiate Doc, I do not get the error. It seems to be related to parsing, since even this will cause the "Document Contains No Data" error:

    if (0) {
       $d = new Doc();
    }

    Obviously, line 2 won't even execute, but I still get the error. If I comment out line 2, the page loads. The class itself is very simplistic. Just a few instance variables and a constructor method that sets their values. I've tried commenting out the constructor. No good. Changing the name of the class. No good. All of my other classes work.

    I've also found that on one server, the error occurs only about 5% of the time. On the other server, it occurs 100% of the time.

    Riddle me this: What's going on here?



    [This message has been edited by riddler (edited 12-07-99).]
  10. #6
  11. No Profile Picture
    rod k
    Guest
    Devshed Newbie (0 - 499 posts)
    Does your class definition include a constructor? If it doesn't you shouldn't use the () after the class name in the instantiation.

    When instantiating an object that has no constructor or where the constructor does not accept arguments you should declare an object thusly:

    $d = new Doc;

    That might be the problem. The interpreter shouldn't choke on it if it doesn't like it but it might. I don't have access to a php server at the moment to test it. Interesting....

    BTW, the interpreter will try to parse the line even if it won't execute that line because it doesn't KNOW, yet, that the line will never evaluate because of the way you've written the IF statement. IOW, you can get a parse error on that line even if the line will never execute.

    As for the differences in servers... different versions of PHP perhaps? Or one using module, the other cgi?
  12. #7
  13. No Profile Picture
    riddler
    Guest
    Devshed Newbie (0 - 499 posts)
    It does include a constructor that receives an object as an argument. I simplified the code in my last message. In reality, I instantiate the class like this:

    $row = mysql_fetch_object ($result);
    $d = new Doc ($row);

    The class looks something like this:

    class Doc {

      var $DocID = 0;
      var $Recd = "0000-00-00";
    (etc.)

      function Doc ($row) {
        $this->DocID = $row->DocID;
    (etc.)
      }
    }

    I know that the parser checks ALL code, not just that which would be executed; but why not generate a parse error if something is wrong? Why the silent treatment?



    [This message has been edited by riddler (edited 12-07-99).]
  14. #8
  15. No Profile Picture
    rod k
    Guest
    Devshed Newbie (0 - 499 posts)
    Aahhhhh! Now we've hit upon it. You know that PHP is not really an OOP language and nesting or referring to objects within objects can be a bit of a problem. (The reason you're not getting a parse error may be that the interpreter is choking on the code, recognizing it is a valid but unable to execute it???)

    Pass and refer to $row as an array instead, see if that clears it up.

  16. #9
  17. No Profile Picture
    riddler
    Guest
    Devshed Newbie (0 - 499 posts)
    Damn. I think you're probably right. Does this mean that it is also a bad idea for a property of Class1 to be of data-type Class2?

    There go my plans for a fully OO approach. (I had planned to have a few levels of object nesting.)

    I won't be able to test your idea until Thursday, but I think you hit it. Thank you.

    Any idea why it might (pretty much) work on one server, and not at all on the other?

  18. #10
  19. No Profile Picture
    rod k
    Guest
    Devshed Newbie (0 - 499 posts)
    Well, you could always give PHP4 a try. I understand that it handles OOP better, though I can't speak from experience and it is still in Beta.

    As for why it works on one albiet sporadically and not the other may have to do with what I mentioned earlier.. different versions and/or module vs cgi.

Similar Threads

  1. Replies: 2
    Last Post: February 15th, 2004, 05:22 PM
  2. Codepupil
    By Adachic in forum C Programming
    Replies: 3
    Last Post: February 6th, 2004, 06:50 PM
  3. post data to new window then do redirect
    By theDano in forum PHP Development
    Replies: 2
    Last Post: January 24th, 2004, 06:08 PM
  4. my comp sux lately , need help from pro's
    By Hykinsel007 in forum Windows Help
    Replies: 2
    Last Post: January 5th, 2004, 01:52 PM
  5. data for two table cells
    By menator in forum PHP Development
    Replies: 1
    Last Post: December 24th, 2003, 09:17 PM

IMN logo majestic logo threadwatch logo seochat tools logo