I have tried a few different pdf classes on my website, all of them work locally, but when uploaded to my hosting server (Gocrappy-daddy) it doesnt work. Every time it says the PDF is corrupt. The pdf library is not installed on their server and I didnt think it was an issue with classes such as ezpdf. No errors are displaying on the logs either. Here is my code.
<?php
require_once('config.php');
//Array to store validation errors
$errmsg_arr = array();
//Validation error flag
$errflag = false;
//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
//Select database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Unable to select database");
}
$rnum = $_GET["tra"];
$sql = "SELECT * FROM accounting WHERE ID = '$rnum'";
$itemList = mysql_query($sql);
while($row = mysql_fetch_array($itemList))
{
$first = $row["FirstName"];
$last = $row["LastName"];
$amount = $row["Amount1"];
$amount = sprintf("%01.2f", $amount);
$amount2 = $row["Amount2"];
$amount2 = sprintf("%01.2f", $amount2);
$method2 = $row["Amount2RS"];
$reason = $row["Amount1RS"];
$method = $row["Amount1Type"];
$polnum = $row["PolNum"];
$totcol = $row["TotalCollected"];
$day = substr($row["Date"], 8, 2);
$month = substr($row["Date"], 5, 2);
$year = substr($row["Date"], 0, 4);
$hour = substr($row["Date"], 11, 2);
$minute = substr($row["Date"], 14, 2);
$second = substr($row["Date"], 17, 2);
if($hour > 12)
{
$hour = $hour - 12;
$meridian = "PM";
}
elseif($hour == 12)
{
$meridian = "PM";
}
elseif($hour == 0)
{
$hour = 12;
$meridian = "AM";
}
else
{
$meridian = "AM";
}
$now = $month."/".$day."/".$year." ".$hour.":".$minute.":".$second." ".$meridian;
}
$text = "Receipt From \n";
$text1 = $_SESSION['SESS_AGENCY'];
$text2 = "This receipt does not guarantee coverage.";
require_once('class.ezpdf.php');
$pdf =& new Cezpdf();
$pdf->selectFont('./fonts/Courier-Bold.afm');
$data = array(
array('Receipt'=>'Client Name', 'Client'=>$first . " " .$last),
array('Receipt'=>'Amount 1', 'Client'=>$amount),
array('Receipt'=>'Description', 'Client'=>$method),
array('Receipt'=>'Amount 2', 'Client'=>$amount2),
array('Receipt'=>'Description', 'Client'=>$method2),
array('Receipt'=>'Reason', 'Client'=>$reason),
array('Receipt'=>'Total Collected', 'Client'=>$totcol),
array('Receipt'=>'Date', 'Client'=>$now));
$pdf->addText(70, 180, 14, $text.$text1);
$pdf->addText(70, 160, 14, $text2);
$pdf->ezTable($data,array('Receipt'=>'','Client'=>''),''
,array('showHeadings'=>0
,'shaded'=>0
,'width'=>400,'fontSize' => 14));
$pdf->ezStream();
?>