I have used this in the past and for some reason it won't work now. Nothing on the server has changed and the old pages work fine. I have a php script that i use to look up customers in a MySql DB. This works fine. I have a link in the page for the customer info that takes the user to another page. The url comes out like this .///statementpdf.php?accountid = 1234 here is my code for that page:
<?php
define('FPDF_FONTPATH','font/');
require('mysql_table.php');
$accountcode= $_GET['accountid'];
class PDF extends PDF_MySQL_Table
{
function Header()
{
//Title
$this->SetFont('Arial','',18);
$this->Cell(0,50,'Account Statement',0,1,'C'); //the second number in the Cell(x,yy,) is the vertical position of the line
$this->Ln(10);
//Ensure table header is output
parent::Header();
}
}
//Connect to database
mysql_connect('localhost','admin','9axmy425');
mysql_select_db('vtigercrm50');
//***********Get Billing Info **************
$sql = 'SELECT'
. ' `vtiger_account`.`accountname`,'
. ' `vtiger_accountbillads`.`accountaddressid`,'
. ' `vtiger_accountbillads`.`bill_street`,'
. ' `vtiger_accountbillads`.`bill_city`,'
. ' `vtiger_accountbillads`.`bill_state`,'
. ' `vtiger_accountbillads`.`bill_code`,'
. ' `vtiger_account`.`phone`,'
. ' `vtiger_account`.`fax`'
. ' FROM'
. ' `vtiger_account`'
. ' Inner Join `vtiger_accountbillads` ON `vtiger_account`.`accountid` = `vtiger_accountbillads`.`accountaddressid`'
. ' WHERE'
. ' `vtiger_account`.`accountid` = '$accountcode' ';
$result=mysql_query($sql);
$row=mysql_fetch_assoc($result);
$customername =$row['accountname'];
$fax=$row['fax'];
$address=$row['bill_street'];
$city=$row['bill_city'];
$state=$row['bill_state'];
$code=$row['bill_code'];
$phone=$row['phone'];
//*************Close *******************
/*
//********************Outstanding Balance Query*********************
$dataquery = "SELECT SUM(total) As balance
FROM vtiger_invoice Where accountid = '$myvar' and invoicestatus Not Like "Paid"";
$result=mysql_query($dataquery);
$rowdata=mysql_fetch_row($result);
$Balance=$rowdata[0];
$bal = Number_Format ($Balance,2);
//*************************30 Days or less******************************************
$dataquery2 = "SELECT SUM(total) As over30
FROM vtiger_invoice Where invoicedate >=Date_sub(Curdate(),interval 30 Day) and accountid = '$myvar' and invoicestatus Not Like "Paid"";
$result=mysql_query($dataquery2);
$rowdata=mysql_fetch_row($result);
$over30days=$rowdata[0];
$over30 = Number_Format ($over30days,2);
//********************************************************************
//**********************************Last 60 Days********************************
$dataquery3 = "SELECT SUM(total) As over60
FROM vtiger_invoice Where invoicedate >=Date_sub(Curdate(),interval 60 Day) and accountid = '$myvar' and invoicestatus Not Like "Paid"";
$result=mysql_query($dataquery3);
$rowdata=mysql_fetch_row($result);
$over60days=$rowdata[0];
$over60 = Number_Format ($over60days,2);
//*********************************************************************************
*/
$pdf=new PDF();
$pdf->Open();
$pdf->AddPage();
$pdf->Image('cqilogo.png',5,4,50);
$pdf->SetFont('Times','B',12);
$pdf->Cell(1,-55,'Customer :');
$pdf->SetFont('Times','',10);
$pdf->Cell(1,-45,$customername);
$pdf->Cell(-1,-38,$address);
$pdf->Cell(30,-31,$city,",");
$pdf->Cell(8,-31,$state);
$pdf->Cell(-40,-31,$code);
$prop=array('HeaderColor'=>array(255,150,100),
// 'color1'=>array(210,245,255),
// 'color2'=>array(255,255,210),
'padding'=>2);
$pdf->Table('SELECT'
. ' vtiger_invoice.invoice_no,'
. ' vtiger_invoice.invoicestatus,'
. ' FORMAT(vtiger_invoice.total,2)AS Total,'
. ' DATE_FORMAT(vtiger_invoice.invoicedate,\'%m/%d/%Y\') AS InvDate,'
. ' DATE_FORMAT(vtiger_invoicecf.cf_674,\'%m/%d/%Y\') AS Paid'
. ' FROM'
. ' vtiger_invoice'
. ' Inner Join vtiger_invoicecf ON vtiger_invoicecf.invoiceid = vtiger_invoice.invoiceid'
. ' WHERE'
. ' vtiger_invoice.accountid = "$myvar"'
. ' ORDER BY'
. ' vtiger_invoice.accountid ASC',$prop);
$pdf->SetFont('Times','',10);
$pdf->Cell(30,10,'Outstanding Balance:$');
$pdf->Cell(20,10,$bal,0,0,R);
$pdf->Cell(20,10,'Less Than 30 Days:$');
$pdf->Cell(20,10,$over30,0,0,R);
$pdf->Cell(25,10,'Less Than 60 Days:$');
$pdf->Cell(20,10,$over60,0,0,R);
$pdf->Cell(20,10,'Please Pay Now: $');
$pdf->Cell(20,10,$paynow,0,0,R);
$pdf->Output();
?>
My problem is that the accountid does not get to the variable and into the MySql query, so I get no data. If I manually insert an accountid I get all the data I need. So the issue is somewhere in getting the accountid into the query. The PDF gets created fine. I have been searching for answere as to why this won't work for two days now. I commented out the other queries. At this point if I can get the first query to work I can make the others.
Thanks for looking and any suggestions!!