我无法使用此脚本输出邮件标签的pdf。它抛出此错误: 解析错误:语法错误,意外的$ end
<?php
define('FPDF_FONTPATH','/home/directory/public_html/sub/font/');
require_once('fpdf.php');
//Connect to your database
mysql_connect("localhost", "db_user","db_pw") or
die ("Could not connect to database");
mysql_select_db("database_name") or
die ("Could not select database");
$query = "SELECT employee_name, street_address, City, state, zip_code FROM employees ORDER BY `employee_name` ";
$result = mysql_query($query) or die('Error, query failed');
$num_rows = mysql_num_rows($result);
function PrintAddressLabels($result){
$pdf=new FPDF();
$pdf->Open();
$pdf->AddPage();
$pdf->SetFont('Arial','B',14);
$pdf->SetMargins(0,0);
$pdf->SetAutoPageBreak(false);
$x = 0;
$y = 0;
$i=0;
while (TRUE) {
if ($row=$result[$i]) {
//positions set above
$LabelText = sprintf("%s\n%s %s\n%s, %s, %s",
$row['employee_name'],
$row['street_address'],
$row['City'],
$row['state'],
$row['zip_code']);
Avery5160($x,$y,&$pdf,$LabelText);
$y++; // next row
if ($y == 10 ) { // end of page wrap to next column
$x++;
$y = 0;
if ($x == 3 ) { // end of page
$x = 0;
$y = 0;
$pdf->AddPage();
}
}
$i++; //counter through result
} else {
// Error quit printing
break;
}
{
$pdf->Output('mailing_labels.pdf','D');
}
?>
答案 0 :(得分:1)
在输出pdf之前,您的{
应为}
。
我已经格式化了您发布的代码,以便缩进块。这样可以更轻松地找到错过}
的位置。
答案 1 :(得分:0)
您似乎错过了}
的匹配while()
。或者你的功能..