0

This question has been answered (see below question)

Original Question: I built a website that works correctly and has no issues. Then we started a migration from a VPS based server to a true dedicated server. While doing this, our hosting company upgraded us from CentOS 4 to CentOS 6, from PHP 5.2.9 to PHP 5.3 and switched us from DSO to SuPHP. Now the new server is causing an error that we did not have before. One of our pages is showing blank and I have narrowed it down to a single line of code (line 26).

1.  class directoryByLetterReverse{
2.      private $da=0;
3.      public $category;
4.      public $letter;
5.      public $listing;
6.      function __construct($letter,$category,$conn){
7.          $this->letter=$letter;
8.          $this->category=$category;
9.          $recordSet=&$conn->Execute('SELECT members.Member_ID AS MemberID, companies.CompanyName AS CompanyName, members.IPAddress AS IPAddress, directory_table.dir_id, members.BusinessType_ID, members.MemberType FROM members Inner Join companies ON companies.Company_ID = members.Company_ID Left Join directory_table ON directory_table.member_id = members.Member_ID WHERE companies.CompanyName LIKE "'.$this->letter.'%" AND members.BusinessType_ID LIKE "'.$this->category.'" AND members.published="1" ORDER BY directory_table.dir_id DESC, members.Member_ID DESC;');
10.         if(!$recordSet){
11.             print $conn->ErrorMsg();
12.         } else {
13.             $this->listing[0]['memberid']=''.$recordSet->fields[0].'';
14.             $this->listing[0]['companyname']=''.$recordSet->fields[1].'';
15.             $this->listing[0]['ipaddress']=''.$recordSet->fields[2].'';
16.             $this->listing[0]['dirid']=''.$recordSet->fields[3].'';
17.             $this->listing[0]['typeid']=''.$recordSet->fields[4].'';
18.             $this->listing[0]['memtype']=''.$recordSet->fields[5].'';
19.             while($array=$recordSet->FetchRow()){
20.                 $this->da++;
21.                 $this->listing[$this->da]['memberid']=''.$recordSet->fields[0].'';
22.                 $this->listing[$this->da]['companyname']=''.$recordSet->fields[1].'';
23.                 $this->listing[$this->da]['ipaddress']=''.$recordSet->fields[2].'';
24.                 $this->listing[$this->da]['dirid']=''.$recordSet->fields[3].'';
25.                 $this->listing[$this->da]['typeid']=''.$recordSet->fields[4].'';
26.                 $this->listing[$this->da]['memtype']=''.$recordSet->fields[5].'';   < - - - - this line right here is what is causing the problem
27.             };
28.         };
29.     }
30.     function returnSingle($j){
31.         return $this->listing[$j]['memberid'].' '.$this->listing[$j]['companyname'].' '.$this->listing[$j]['ipaddress'].' '.$this->listing[$j]['dirid'];
32.     }
33. }

For the life of me I cannot find anything wrong with line 26, but if I leave it there, I get a blank page, if I comment it out, everything works (until you go to a page that references it but that I would expect to be broken).

Also, just a a side note, I am using ADOdb Database Abstraction Library (http://adodb.sourceforge.net/) for the MySQL interaction.

Turns out there is in fact nothing wrong with the code, the testing server simply has limited performance and was not able to handle the load of an uncached page loading. thank you for the comments as they got me thinking in the right direction to find what i needed.

  • Which is the single line of code you narrowed it down to? – dweiss May 01 '12 at 21:25
  • oops, I edited the post, but it is line 26 – Spenser David Fishel May 01 '12 at 21:26
  • What error are you getting? Do you log PHP errors? Do you log the apache errors? – hakre May 01 '12 at 21:28
  • enable error_reporting, display_errors or log_errors and check the log file. Maybe $recordSet->fields[5] does not exist (E_NOTICE). Hard to say that without knowledge of the error message. – MonkeyMonkey May 01 '12 at 21:29
  • Is memberType null in one of the records? This is my guess. fields[5] does exist otherwise because it's referenced earlier and works fine. However, it's possible that not *every* record has this and therefore doesn't always exist. – dweiss May 01 '12 at 21:32
  • Does this error out the FIRST time line 26 is reached, or only after multiple runs through it? – Marc B May 01 '12 at 21:32
  • error logs are not showing anything and php isn't throwing an error, I just get a blank page – Spenser David Fishel May 01 '12 at 21:33
  • there are instances of memberType being null, there are however instances of every field other than memberid being null also with no problems. if I change $this->da to an actual number on line 26, the file works – Spenser David Fishel May 01 '12 at 21:35
  • so Marc B got me thinking and I added a conditional statement before that line ran that said if($this->da<50){ etc. and it worked (so it must be able to run 50 times, so I tried a few different counts trying to narrow down where it is crashing. turns out once it runs just over 8000 times, halfway through the page, it hits a Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 695 bytes) in /home/<...>/directory/listingClasses.php on line 218, which makes me think that because the new enviorenment is still on a testing server, they probably have it limited – Spenser David Fishel May 01 '12 at 21:47
  • OP: you should answer your own question then – SlackOverflow Feb 11 '14 at 21:32

1 Answers1

0

And without the ";" of line 27 and 28, still doesn't work ?

Kalzem
  • 7,320
  • 6
  • 54
  • 79
  • tried that too, infact i added them in trying to get it to work, makes no difference. but if i put a // at the begining of line 26, everything just starts working – Spenser David Fishel May 01 '12 at 21:30