Autor
		 | 
		
			Tema: php variable indefinida  (Leído 3,550 veces)
		 | 
	 
 
	
		
			
				
					
						
							geshiro
							
								
								  Desconectado
								Mensajes: 178
								
								
								
								
								
								  
							 
						 | 
						
							
							 
							
hola buenas tardes en mi proyecto instale una libreria para hacer pdfs con php pero al momento de querer declarar la variable me dice variable indefinida <?php 	require('../fpdf/fpdf.php'); 	class PDF extends FPDF{ 		private $conexion; 		public function __construct(){ 			require('conexion.php'); 			$this->conexion = new conexion(); 			$this->conexion->conectar(); 		} 	}   	$pdf = new FPDF(); 	$pdf->AddPage(); 	$pdf->SetFont('Arial', '', 10); 	$pdf->Image('../assests/img/tienda.gif' , 10 ,8, 10 , 13,'GIF'); 	$pdf->Cell(18, 10, '', 0); 	$pdf->Cell(150, 10, 'Store "Aron Imperial"', 0); 	$pdf->SetFont('Arial', '', 9); 	$pdf->Cell(50, 10, 'Hoy: '.date('d-m-Y').'', 0); 	$pdf->Ln(15); 	$pdf->SetFont('Arial', 'B', 11); 	$pdf->Cell(70, 8, '', 0); 	$pdf->Cell(100, 8, 'List product', 0); 	$pdf->Ln(23); 	$pdf->SetFont('Arial', 'B',8); 	$pdf->Cell(15, 8, 'Code', 0); 	$pdf->Cell(50, 8, 'Product', 0); 	$pdf->Cell(25, 8, 'Price', 0); 	$pdf->Cell(25, 8, 'Stock', 0); 	$pdf->Ln(8); 	$pdf->SetFont('Arial','',8); 	$record = $product->query("SELECT * FROM product"); 	$pdf->Output(); ?>   
 
 los errores  Notice: Undefined variable: product in C:\xampp\htdocs\store\fpdf\list_product.php on line 32 Fatal error: Call to a member function query() on null in C:\xampp\htdocs\store\fpdf\list_product.php on line 32 
  
						 | 
					 
					
						
							
								| 
								 | 
							 
								| 
								 | 
								
									 
									En línea
								 | 
							  
							 
							
						 | 
					 
				 
			 |  
		 
	 |  
	| 
		
		
	 |  
	
		
		
			
				
					
						
							geshiro
							
								
								  Desconectado
								Mensajes: 178
								
								
								
								
								
								  
							 
						 | 
						
							
							 
							
no puedo cambiarla ya que todo el proyecto trabaja en POO y no puedo cambiarla  
						 | 
					 
					
						
							
								| 
								 | 
							 
								| 
								 | 
								
									 
									En línea
								 | 
							  
							 
							
						 | 
					 
				 
			 |  
		 
	 |  
	
		
		
			
				
					
						
							geshiro
							
								
								  Desconectado
								Mensajes: 178
								
								
								
								
								
								  
							 
						 | 
						
							
							 
							
cuando intento hacer esto  <?php 	require('fpdf.php'); 	class PDF extends FPDF{ 		private $conexion; 		public function __construct(){ 			require('../models/conexion.php'); 			$this->conexion = new conexion(); 			$this->conexion->conectar(); 		} 	}   	$pdf = new PDF(); 	$pdf->AddPage(); 	$pdf->SetFont('Arial', '', 10); 	$pdf->Image('../assests/img/tienda.gif' , 10 ,8, 10 , 13,'GIF'); 	$pdf->Cell(18, 10, '', 0); 	$pdf->Cell(150, 10, 'Store "Aron Imperial"', 0); 	$pdf->SetFont('Arial', '', 9); 	$pdf->Cell(50, 10, 'Hoy: '.date('d-m-Y').'', 0); 	$pdf->Ln(15); 	$pdf->SetFont('Arial', 'B', 11); 	$pdf->Cell(70, 8, '', 0); 	$pdf->Cell(100, 8, 'List product', 0); 	$pdf->Ln(23); 	$pdf->SetFont('Arial', 'B',8); 	$pdf->Cell(15, 8, 'Code', 0); 	$pdf->Cell(50, 8, 'Product', 0); 	$pdf->Cell(25, 8, 'Price', 0); 	$pdf->Cell(25, 8, 'Stock', 0); 	$pdf->Ln(8); 	$pdf->SetFont('Arial','',8); 	$pdf->Output(); ?>   
 
 me esta esto otro error  Warning: in_array() expects parameter 2 to be array, null given in C:\xampp\htdocs\store\fpdf\fpdf.php on line 501 Fatal error: Uncaught exception 'Exception' with message 'FPDF error: Undefined font: helvetica ' in C:\xampp\htdocs\store\fpdf\fpdf.php:271 Stack trace: #0 C:\xampp\htdocs\store\fpdf\fpdf.php(510): FPDF->Error('Undefined font:...') #1 C:\xampp\htdocs\store\fpdf\list_product.php(14): FPDF->SetFont('Arial', '', 10) #2 {main} thrown in C:\xampp\htdocs\store\fpdf\fpdf.php on line 271  
						 | 
					 
					
						
							
								| 
								 | 
							 
								| 
								 | 
								
									 
									En línea
								 | 
							  
							 
							
						 | 
					 
				 
			 |  
		 
	 |  
	
		
		
			
				
					
						
							geshiro
							
								
								  Desconectado
								Mensajes: 178
								
								
								
								
								
								  
							 
						 | 
						
							
							 
							
ahora si me deja acceder pero ahora query no puedo usarlo porque dice que no esta definido Fatal error: Call to undefined method PDF::query() in C:\xampp\htdocs\store\fpdf\list_product.php on line 33 <?php 	require('fpdf.php'); 	class PDF extends FPDF{ 		private $conexion; 		public function __construct(){ 			require('../models/conexion.php'); 			$this->conexion = new conexion(); 			$this->conexion->conectar(); 			parent::__construct(); 		} 	}   	$pdf = new PDF(); 	$pdf->AddPage(); 	$pdf->SetFont('Arial', '', 10); 	$pdf->Image('../assests/img/tienda.gif' , 10 ,8, 10 , 13,'GIF'); 	$pdf->Cell(18, 10, '', 0); 	$pdf->Cell(150, 10, 'Store "Aron Imperial"', 0); 	$pdf->SetFont('Arial', '', 9); 	$pdf->Cell(50, 10, 'Hoy: '.date('d-m-Y').'', 0); 	$pdf->Ln(15); 	$pdf->SetFont('Arial', 'B', 11); 	$pdf->Cell(70, 8, '', 0); 	$pdf->Cell(100, 8, 'List product', 0); 	$pdf->Ln(23); 	$pdf->SetFont('Arial', 'B',8); 	$pdf->Cell(15, 8, 'Code', 0); 	$pdf->Cell(50, 8, 'Product', 0); 	$pdf->Cell(25, 8, 'Price', 0); 	$pdf->Cell(25, 8, 'Stock', 0); 	$pdf->Ln(8); 	$pdf->SetFont('Arial','',8); 	$pdf->query("SELECT * FROM product"); 	$pdf->Output(); ?>     
 
  
						 | 
					 
					
						
							
								| 
								 | 
							 
								| 
								 | 
								
									 
									En línea
								 | 
							  
							 
							
						 | 
					 
				 
			 |  
		 
	 |  
	
		
		
			
				
					
						
							eLank0
							
								eLhAcKeR r00Lz 
								       
								
								  Desconectado
								Mensajes: 1.062
								
								 
								
								
								
								
								 
								 
							 
						 | 
						
							
							 
							
Te aconsejo que te leas bien los errores antes de continuar. Si pone undefined method es que no existe el método, ya que en este caso debería ser: $sql_statement = "SELECT user.Host, user.User, user.Password, Select_priv as `Select priv`, Insert_priv as `Insert Priv`, Update_priv as `Update priv`, Delete_priv as `Delete priv`, Create_priv as `Create priv`, Reload_priv as `Reload priv`, Shutdown_priv as `Shutdown priv`, Process_priv as `Process priv`, File_priv as `File priv`, Grant_priv as `Grant priv`, References_priv as `References priv`, Index_priv as `Index priv` FROM user LEFT JOIN tables_priv ON user.User=tables_priv.User ORDER BY user.User" ;   // Generate report $pdf->mysql_report($sql_statement, false, $attr );     /*!!! Very Important: after having done all the work of    setting up the SQL don't forget to output the PDF else   you just get a blank page !!!*/   $pdf->Output(); 
 
 El código está extraido de la web oficial de fPDF. http://www.fpdf.org/en/script/script21.phpSalu2  
						 | 
					 
					
						
							
								| 
								 | 
							 
								| 
								 | 
								
									 
									En línea
								 | 
							  
							 
							
						 | 
					 
				 
			 |  
		 
	 |  
	 |  
 
	 
	
 
			 
			
				
					
						| Mensajes similares | 
					 
					
						 | 
						Asunto | 
						Iniciado por | 
						Respuestas | 
						Vistas | 
						Último mensaje | 
					 
					
						
							 
						 | 
						
							 
						 | 
						
							La variable de tipo Object o la variable de bloque With no está establecida
							 
							Programación Visual Basic
						 | 
						
							rubeng
						 | 
						
							5
						 | 
						
							12,835
						 | 
						
							 
							
								17 Septiembre 2007, 00:04 am 
								por rubeng
							
						 | 
					 
					
						
							 
						 | 
						
							 
						 | 
						
							Error 91: Variable de tipo object o la variable de bloque with no esta estableci
							 
							Programación Visual Basic
						 | 
						
							brus_k10
						 | 
						
							2
						 | 
						
							7,144
						 | 
						
							 
							
								16 Junio 2009, 16:20 pm 
								por cassiani
							
						 | 
					 
					
						
							 
						 | 
						
							 
						 | 
						
							my.resources.source.replace(variable, variable) Ayuda codedom
							 
							.NET (C#, VB.NET, ASP)
						 | 
						
							70N1
						 | 
						
							4
						 | 
						
							5,841
						 | 
						
							 
							
								19 Octubre 2011, 12:57 pm 
								por 70N1
							
						 | 
					 
					
						
							 
						 | 
						
							 
						 | 
						
							Asignar un valor a una variable(ScriptA)Obtener esa variable (ScriptB)-UNITY c#
							 
							Programación General
						 | 
						
							USLO
						 | 
						
							1
						 | 
						
							5,847
						 | 
						
							 
							
								 8 Octubre 2013, 17:51 pm 
								por Eleкtro
							
						 | 
					 
					
						
							 
						 | 
						
							 
						 | 
						
							MOVIDO: Asignar un valor a una variable(ScriptA)Obtener esa variable (ScriptB)-UNITY c#
							 
							Scripting
						 | 
						
							Eleкtro
						 | 
						
							0
						 | 
						
							3,588
						 | 
						
							 
							
								 8 Octubre 2013, 17:49 pm 
								por Eleкtro
							
						 | 
					 
				 
			    |