PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 3rd, 1999, 10:47 AM
riddler
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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?

Reply With Quote
  #2  
Old December 3rd, 1999, 11:25 AM
rod k
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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.

Reply With Quote
  #3  
Old December 3rd, 1999, 03:55 PM
riddler
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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?

Reply With Quote
  #4  
Old December 4th, 1999, 07:44 AM
rod k
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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.

Reply With Quote
  #5  
Old December 7th, 1999, 11:39 AM
riddler
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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).]

Reply With Quote
  #6  
Old December 7th, 1999, 12:14 PM
rod k
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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?

Reply With Quote
  #7  
Old December 7th, 1999, 01:16 PM
riddler
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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).]

Reply With Quote
  #8  
Old December 7th, 1999, 01:49 PM
rod k
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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.


Reply With Quote
  #9  
Old December 7th, 1999, 06:49 PM
riddler
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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?


Reply With Quote
  #10  
Old December 8th, 1999, 06:54 AM
rod k
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Document Contains No Data

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap