Link to home
Start Free TrialLog in
Avatar of breeze351
breeze351

asked on

Problem with vars being "undefined" in one inclusion but not another even though they are both accesing the same table

PHP: Can't figure out why vars are coming up as undefined.

I have a bunch of inclusions to do the printing with FPDF.  

The one line works with both printing one at a time and print all.
The full format works if you print one at a time, but when I select print all I get the following error message:

Notice: Undefined index: SECOND in /home/langsyst/public_html/seabreezesoftware/Retail/Full_Format_PDF_inc.php on line 205

The table layout is this:
16       STORE       int(6)                   Yes       0                   Change Change       Drop Drop       

    Primary Primary
    Unique Unique
    Index Index
    More

17       BASEMENT       int(5)                   Yes       0                   Change Change       Drop Drop       

    Primary Primary
    Unique Unique
    Index Index
    More

18       MEZZANINE       int(5)                   Yes       0                   Change Change       Drop Drop       

    Primary Primary
    Unique Unique
    Index Index
    More

19       SECOND       int(5)                   Yes       0                   Change Change       Drop Drop       

    Primary Primary
    Unique Unique
    Index Index
    Mor

The one line code is:
while ($ROW = $Survey_Data->fetch_array())  
	{
		if ($_SESSION['Last_Page'] == "Space_Edit.php")
		{
			// Footage
			$ROW['STORE'] = $_POST['Store'];
			$ROW['BASEMENT'] = $_POST['Basement'];
			$ROW['MEZZANINE'] = $_POST['Mezzanine'];
			$ROW['SECOND'] = $_POST['Second'];
			$ROW['OTHER'] = $_POST['Other'];			
			$ROW['TOTAL'] = $ROW['STORE'] + $ROW['BASEMENT'] + $ROW['MEZZANINE'] + $ROW['SECOND'] +$ROW['OTHER'];
			
			// Sizes
			$ROW['FRONTAGE'] = $_POST['Frontage'];
			$ROW['CEILING'] = $_POST['Ceiling'];
			$ROW['DEPTH'] = $_POST['Depth'];
			
			// Rentals
			$ROW['RENT'] = $_POST['$PSF'];
			$ROW['MONTHLY'] = $_POST['Month'];
			$ROW['ANNUAL'] = $_POST['Annual'];
			
			// Possesion, Terms And Remarks
			$ROW['POSSESSION'] = $_POST['Possession'];
			$ROW['TERM'] = $_POST['Term'];
			$ROW['REMARK1'] = $_POST['Remark1'];
			$ROW['REMARK2'] = $_POST['Remark2'];
			$ROW['REMARK3'] = $_POST['Remark3'];
			$ROW['REMARK4'] = $_POST['Remark4'];
			$ROW['REMARK5'] = $_POST['Remark5'];
			$ROW['REMARK6'] = $_POST['Remark6'];
			
		}
		if ($Line_Count > "8")
		{
			$Line_Count = "6";
			$pdf->AddPage();
			$pdf->SetX(10);
			$work = "Page: ".$Page_No;
			$pdf->Cell(10, 5,$work, 0, 0, "L");
			$pdf->Cell(0, 15,'L A N S C O',0,0,'C');
			$today = date("F j, Y, g:i a");	
			$pdf->SetX(265);	 
			$pdf->Cell(10, 15, $today, 0, 4, "R");
			$pdf->SetX(10);
			$pdf->Cell(60,5,'Address', 1, 0, "L");
			$pdf->SetX(70);
			$pdf->Cell(80,5,'Contact', 1, 0, "L");		
			$pdf->SetX(150);
			$pdf->Cell(20,5,'Gr/Bs/Tot. ', 1, 0, "L");
			$pdf->SetX(170);
			$pdf->Cell(20,5,' $SF/Mo/An', 1, 0, "R");
			$pdf->SetX(190);
			$pdf->Cell(40,5,'Possesion/Term', 1, 0, "R");
			$pdf->SetX(230);
			$pdf->Cell(40,5,'List/Update', 1, 0, "L");		
			$pdf->SetX(250);
			$pdf->Cell(20,5,'Image', 1, 1, "R");
			$Page_No++;			
		}

					
		
		$work = number_format("$ROW[STORE]");
		$Ground = $work;
		
		$work = number_format("$ROW[BASEMENT]");
		$Basement = $work;
		
		$work = number_format("$ROW[TOTAL]");
		$Total = $work;
		
		$work = ("$ROW[RENT]");
		$Rent = $work;

Open in new window


The full format code is:
while ($ROW = $Survey_Data->fetch_array())  
	{
		if ($_SESSION['Last_Page'] == "Space_Edit.php")
		{
			// Footage
			$ROW['STORE'] = $_POST['Store'];
			$ROW['BASEMENT'] = $_POST['Basement'];
			$ROW['MEZZANINE'] = $_POST['Mezzanine'];
			$ROW['SECOND'] = $_POST['Second'];
			$ROW['OTHER'] = $_POST['Other'];			
			$ROW['TOTAL'] = $_POST['Total'];
			
			// Sizes
			$ROW['FRONTAGE'] = $_POST['Frontage'];
			$ROW['CEILING'] = $_POST['Ceiling'];

			$ROW['DEPTH'] = $_POST['Depth'];
			
			// Rentals
			$ROW['RENT'] = $_POST['$PSF'];
			$ROW['MONTHLY'] = $_POST['Month'];
			$ROW['ANNUAL'] = $_POST['Annual'];
			
			// Possesion, Terms And Remarks
			$ROW['POSSESSION'] = $_POST['Possession'];
			$ROW['TERM'] = $_POST['Term'];
			$ROW['REMARK1'] = $_POST['Remark1'];
			$ROW['REMARK2'] = $_POST['Remark2'];
			$ROW['REMARK3'] = $_POST['Remark3'];
			$ROW['REMARK4'] = $_POST['Remark4'];
			$ROW['REMARK5'] = $_POST['Remark5'];
			$ROW['REMARK6'] = $_POST['Remark6'];
			$ROW['REMARK7'] = $_POST['Remark7'];
			$ROW['REMARK8'] = $_POST['Remark8'];
			$ROW['REMARK9'] = $_POST['Remark9'];
			
		}
		
		if ($Line_Count > "1")
		{
			$Line_Count = "0";
			$pdf->AddPage();
			$work = "Page: ".$Page_No;
			$pdf->Cell(5, 5,$work, 0, 0, "L");
			$pdf->Cell(0,5,'L A N S C O',0,3,'C');
			$Page_No++;	
		}
// glenn
	$Building_Id = $ROW['SEQ'];
	$Space_Id = $ROW['STOREKEY'];
		$work = number_format("$ROW[STORE]");
		$Ground = $work;
		
		$work = number_format("$ROW[BASEMENT]");
		$Basement = $work;
		
		$work = number_format("$ROW[MEZZANINE]");
		$Mezzanine = $work;
		
		$work = number_format("$ROW[SECOND]");
		$Second = $work;
		

Open in new window


The 205 line is the $row[second].

Doesn't make sense to me.
Avatar of Robert Granlund
Robert Granlund
Flag of United States of America image

Should it be $work = number_format("$ROW['SECOND']"); with the single quote?
Avatar of breeze351
breeze351

ASKER

Nope! If that was the case, the following would not work:
$work = number_format("$ROW[STORE]");
		$Ground = $work;
		
		$work = number_format("$ROW[BASEMENT]");
		$Basement = $work;
		
		$work = number_format("$ROW[MEZZANINE]");
		$Mezzanine = $work;

Open in new window

This has to be something stupid!
Could it have anything to do with the re-use of the var $work?
I'm attaching all the relevant code:

1. Survey_Print.php gets data from the calling page and then calls the selected print format
2. One_Line_Conatact_PDF_inc.pdf is the inclusions to print one line listings with contact information.  This inclusion works if you print one listing or all the listings displayed on the screen.
3. Full_Format_PDF_inc.pdf is the inclusion to print the listings in full format.  This inclusion works if you print them one at a time.  However, if you click to print them all I'm getting the error that there are undefined variables.

This makes no sense.  The query from Survey_Print.php is selecting all the variables.  I'm not do a select for only selected variables.  Also why would the Full_Format_PDF_inc.pdfSurvey_Print.phpOne_Line_Contact_PDF_inc.php work for one listing and not for them all?
Full_Format_PDF_inc.php
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
What it's doing is that there could be  page behind this where you can change the values of the variables.  That page is "Space_Edit.php".   But the code is the same in the one line and the full format!  Why would it work for one at a time and not "print them all"?
OK. I don't know what you mean by "print them all", so maybe explain that part in a little more detail.

You also say the code is the same in the one line and the full format. If you're referring to One_Line_Contact_PDF_inc and Full_Format_PDF_inc, then clearly the code isn't the same in both - there's quite a bit that's different.

The error that you've been getting indicates that $ROW['SECOND'] doesn't exist. You're not using that in the One_Line file, so it wouldn't throw an error. You are using it Full_Format_PDF and you get the error.

var_dump($row) before using it and I'm sure you'll see that it doesn't have a 'SECOND' index.
Found it.
Got it.