I have a php script sending a single variable within the URL to the next page. it looks something like this ..///statementpdf.php?accountid=4103 If I create a PHP script statementpdf.php with echo $_get ['accountid'}; and run the first script I get the correct result on the page. When I assign a variable to this $_get it doesn't work with my queries in my code. Here's my code:
When this page is opened I get nothing but a blank page. I have several queries and if I manually enter an accountid instead of the $myvar in all of them the page loads fine. Would anyone care to comment on where I went wrong here?
Thanks Alot!
Code:
<?php
define('FPDF_FONTPATH','font/');
require('mysql_table.php');
$myvar= $_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','xxxx','xxxxx');
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 = '$myvar'";
$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 *******************
$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);
//********************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->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();
?>
When this page is opened I get nothing but a blank page. I have several queries and if I manually enter an accountid instead of the $myvar in all of them the page loads fine. Would anyone care to comment on where I went wrong here?
Thanks Alot!