Foros del Web » Programación para mayores de 30 ;) » Bases de Datos General » Mysql »

Parse error: syntax error, unexpected $end in fpdf.php on line 603

Estas en el tema de Parse error: syntax error, unexpected $end in fpdf.php on line 603 en el foro de Mysql en Foros del Web. Hola que tal a todos a ver si me pueden ayudar, por que yo no se hacía donde tirar. Pues bien tengo un archivo donde ...
  #1 (permalink)  
Antiguo 31/07/2012, 04:54
 
Fecha de Ingreso: mayo-2012
Ubicación: Aitona
Mensajes: 20
Antigüedad: 11 años, 11 meses
Puntos: 0
Exclamación Parse error: syntax error, unexpected $end in fpdf.php on line 603

Hola que tal a todos a ver si me pueden ayudar, por que yo no se hacía donde tirar.
Pues bien tengo un archivo donde genero un pdf mediante la biblioteca fpdf, Este archivo php consulta la base de datos y en el where tengo un id que lo paso por url.
Entonces este archivo me funciona perfectamente cuando lo ejecuto en mi ordenador con el localhost.
Però cuando lo subo al servidor me da el siguiente error:
Parse error: syntax error, unexpected $end in /home/a6852231/public_html/imprimir/fpdf/fpdf.php on line 603
No se donde puede estar el error he repasado el código y en fin..., aquí lo dejo por si me pueden echar un cable:



Código:
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && true) {
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "../default.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
<?php require_once('../Connections/conexio_biblioteca.php'); ?>
<?php

require('fpdf/fpdf.php');

class PDF extends FPDF
{
var $widths;
var $aligns;

function SetWidths($w)
{
	//Set the array of column widths
	$this->widths=$w;
}

function SetAligns($a)
{
	//Set the array of column alignments
	$this->aligns=$a;
}

function Row($data)
{
	//Calculate the height of the row
	$nb=0;
	for($i=0;$i<count($data);$i++)
		$nb=max($nb,$this->NbLines($this->widths[$i],$data[$i]));
	$h=5*$nb;
	//Issue a page break first if needed
	$this->CheckPageBreak($h);
	//Draw the cells of the row
	for($i=0;$i<count($data);$i++)
	{
		$w=$this->widths[$i];
		$a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
		//Save the current position
		$x=$this->GetX();
		$y=$this->GetY();
		//Draw the border
		
		$this->Rect($x,$y,$w,$h);

		$this->MultiCell($w,5,$data[$i],0,$a,'true');
		//Put the position to the right of the cell
		$this->SetXY($x+$w,$y);
	}
	//Go to the next line
	$this->Ln($h);
}

function CheckPageBreak($h)
{
	//If the height h would cause an overflow, add a new page immediately
	if($this->GetY()+$h>$this->PageBreakTrigger)
		$this->AddPage($this->CurOrientation);
}

function NbLines($w,$txt)
{
	//Computes the number of lines a MultiCell of width w will take
	$cw=&$this->CurrentFont['cw'];
	if($w==0)
		$w=$this->w-$this->rMargin-$this->x;
	$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
	$s=str_replace("\r",'',$txt);
	$nb=strlen($s);
	if($nb>0 and $s[$nb-1]=="\n")
		$nb--;
	$sep=-1;
	$i=0;
	$j=0;
	$l=0;
	$nl=1;
	while($i<$nb)
	{
		$c=$s[$i];
		if($c=="\n")
		{
			$i++;
			$sep=-1;
			$j=$i;
			$l=0;
			$nl++;
			continue;
		}
		if($c==' ')
			$sep=$i;
		$l+=$cw[$c];
		if($l>$wmax)
		{
			if($sep==-1)
			{
				if($i==$j)
					$i++;
			}
			else
				$i=$sep+1;
			$sep=-1;
			$j=$i;
			$l=0;
			$nl++;
		}
		else
			$i++;
	}
	return $nl;
}

function Header()
{

	$this->SetFont('Arial','',10);
	$this->Text(20,14,'Historial de prèstecs',0,'C', 0);
	$this->Ln(30);
}

function Footer()
{
	$this->SetY(-15);
	$this->SetFont('Arial','B',8);
	$this->Cell(100,10,'Historial de prèstecs',0,0,'L');

}

}

	$dejado= $_GET['id'];
	
	$strConsulta = "SELECT * from usuaris where IdUsuari =  $dejado";
	//echo $strConsulta;
    //  echo $dejados;
	$dejados = mysql_query($strConsulta);
	
	$fila = mysql_fetch_array($dejados);

	$pdf=new PDF('L','mm','Letter');
	$pdf->Open();
	$pdf->AddPage();
	$pdf->SetMargins(20,20,20);
	$pdf->Ln(10);

    $pdf->SetFont('Arial','',12);
    $pdf->Cell(0,6,'DNI: '.$fila['DNI'],0,1);
	$pdf->Cell(0,6,'Nom: '.$fila['nom'].' '.$fila['cognom1'].' '.$fila['cognom2'],0,1);
	$pdf->Cell(0,6,'Sexe: '.$fila['sexe'],0,1);
	$pdf->Cell(0,6,'Domicili: '.$fila['domicili'],0,1);
 
 
	
	$pdf->Ln(10);
	
	$pdf->SetWidths(array(65, 60, 55, 50, 20));
	$pdf->SetFont('Arial','B',10);
	$pdf->SetFillColor(85,107,47);
    $pdf->SetTextColor(255);

		for($i=0;$i<1;$i++)
			{
				$pdf->Row(array('Data deixat','Data tornat', 'Còmic', 'Autor'));
			}
	
	$strConsulta =" SELECT historial.Data_deixat,historial.Data_tornat, historial.comentaris, comic.titol, comic.Dibuixiguio
	FROM historial
	Inner Join usuaris ON historial.id_usuari = usuaris.IdUsuari
	Inner Join comic ON historial.id_comic = comic.IdComic
	WHERE  usuaris.IdUsuari = '$dejado'";
 
 
	
	$historial = mysql_query($strConsulta);
	$numfilas = mysql_num_rows($historial);
	
	for ($i=0; $i<$numfilas; $i++)
		{
			$fila = mysql_fetch_array($historial);
			$pdf->SetFont('Arial','',10);
			
			if($i%2 == 1)
			{
				$pdf->SetFillColor(153,255,153);
    			$pdf->SetTextColor(0);
				$pdf->Row(array($fila['Data_deixat'],$fila['Data_tornat'], $fila['titol'], $fila['Dibuixiguio']));
			}
			else
			{
				$pdf->SetFillColor(102,204,51);
    			$pdf->SetTextColor(0);
				$pdf->Row(array($fila['Data_deixat'],$fila['Data_tornat'], $fila['titol'], $fila['Dibuixiguio']));
			}
		}

$pdf->Output();
?>
<?php
mysql_free_result($usuaris);
?>
Muchas gracias por todo con antelación!!
  #2 (permalink)  
Antiguo 31/07/2012, 06:08
Usuario no validado
 
Fecha de Ingreso: abril-2008
Mensajes: 50
Antigüedad: 16 años
Puntos: 16
Respuesta: Parse error: syntax error, unexpected $end in fpdf.php on line 603

El error se está dando en el archivo "fpdf.php" y puede ser porque la configuración PHP de tu servidor no permite la utilización de etiquetas PHP en formato abreviado.

Yo tuve ese problema en mi hosting y tuve que cambiar los "<?" por "<?php" en todos los "inicios de bloque php" de mis sitios web.

Si por casualidad tienen algo parecido a "<?=$variable?>", lo puedes arreglar poniendo: "<?php echo $variable; ?>".

La verdad es que el error me sonaba y lo he buscado en la red y encontre [URL="http://www.samuelaguilera.com/archivo/parse-error-syntax-error-unexpected-end.xhtml"]esta[/URL] página que me refresco la memoria.

Cito:
Cita:
Parse Error: syntax error, unexpected $end

Es un error bastante común, porque es muy fácil reunir las condiciones para hacerlo saltar.

Basicamente suele deberse a uno de estos dos motivos:

En alguna parte del código falta una llave de cierre (símbolo }, también llamado curly bracket).
El PHP instalado no admite en su configuración el uso de etiquetas PHP en formato abreviado (“<?” en lugar de “<?php” ).
En esa página mencionan como arreglar el problema modificando el php.ini en el servidor, pero lo más saludable es cambiar las etiquetas.
  #3 (permalink)  
Antiguo 07/08/2012, 06:01
 
Fecha de Ingreso: mayo-2012
Ubicación: Aitona
Mensajes: 20
Antigüedad: 11 años, 11 meses
Puntos: 0
Respuesta: Parse error: syntax error, unexpected $end in fpdf.php on line 603

Hola muchas gracias por la pronta contesta i el retardo en contestar pues he hecho unas minivacaciones
He observado el código i no tengo ninguna etiqueta como <? todas son como <?php peró repase el codigo sql mejorando la consulta y ahora me funciona!!
NO se ni lo que he hecho
En fin se agradece la aportación!!

Etiquetas: fpdf, pdf, php
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:18.