Foros del Web » Programando para Internet » PHP »

Notice: Use of undefined constant [php]

Estas en el tema de Notice: Use of undefined constant [php] en el foro de PHP en Foros del Web. Hola que tal, hace poco cree una clase para hacer una paginacion en php, pero me encuentro con un error , les paso la clase ...
  #1 (permalink)  
Antiguo 16/01/2013, 22:56
 
Fecha de Ingreso: septiembre-2012
Ubicación: Buenos aires
Mensajes: 110
Antigüedad: 11 años, 6 meses
Puntos: 9
Pregunta Notice: Use of undefined constant [php]

Hola que tal, hace poco cree una clase para hacer una paginacion en php, pero me encuentro con un error , les paso la clase la forma de uso y el error.


Código PHP:
Ver original
  1. # Mysql
  2.     class Cm_mysql{
  3.                
  4.         # Conexion
  5.         public function Conectar(){
  6.            
  7.             $Conexion = mysql_connect('localhost', 'root', '');
  8.             mysql_select_db('levr',$Conexion);
  9.         }
  10.        
  11.         # Consulta
  12.         public function Consulta($Consulta){
  13.            
  14.             return mysql_query($Consulta);
  15.            
  16.         }
  17.        
  18.         # Reg_Num
  19.         public function Reg_Num($Consulta){
  20.        
  21.             return mysql_num_rows($Consulta);
  22.        
  23.         }
  24.        
  25.         # Assoc
  26.         public function Assoc($Consulta){
  27.        
  28.             return mysql_fetch_assoc($Consulta);
  29.        
  30.         }
  31.        
  32.         # String Search
  33.         public function Con_Like($Consulta,$Por,$Text){
  34.        
  35.             return mysql_query($Consulta.' WHERE '.$Por.' LIKE '.'"'.$Text.'"');
  36.        
  37.         }
  38.        
  39.     }
  40.  
  41.  
  42.  
  43.     # Paginador
  44.     class Cm_Paginador{
  45.        
  46.         # Configuracion
  47.         private $Posicion   = NULL;
  48.         private $Estructura = NULL;
  49.         private $Mysql      = NULL;
  50.         private $Consulta   = NULL;
  51.         private $Paginas    = NULL;
  52.        
  53.         # Mysql
  54.         public function _Mysql($Mysql,$base,$article,$orden,$Posicion){
  55.            
  56.             # Mysql
  57.             $this->Mysql    = $Mysql; $Mysql->Conectar();
  58.             $this->Posicion = $Posicion;
  59.             $Query = "SELECT * FROM ".($base);
  60.             $Exect = $Mysql->Consulta($Query);
  61.            
  62.             # --- Condicionales
  63.             $Cant           = $Mysql->Reg_Num($Exect);
  64.             $this->Paginas  = ceil($Cant/$article);
  65.             $Desde          = $Posicion*$this->Paginas;
  66.        
  67.             # --- Consulta
  68.             $this->Consulta = $Mysql->Consulta($Query.' ORDER BY id '.$orden.' LIMIT '.$Desde.' , '.$Cant);
  69.        
  70.         }
  71.        
  72.         # --- Estructura
  73.         public function _Estructure($estructure){
  74.            
  75.             $this->Estructura = $estructure;
  76.            
  77.         }
  78.        
  79.         # --- Devolucion
  80.         public function _Devolucion(){
  81.            
  82.                    
  83.             while($Campo = $this->Mysql->Assoc($this->Consulta)){
  84.                
  85.                 $str = $this->Estructura;  
  86.                
  87.                 foreach($Campo as $clave => $valor) {
  88.                        
  89.                     $str = str_replace('{'.$clave.'}',$valor,$str);
  90.                    
  91.                    
  92.                 }
  93.                
  94.                 echo $str;
  95.    
  96.             }
  97.            
  98.    
  99.         }
  100.        
  101.         # --- Navegacion
  102.         public function _Navegacion($botones){
  103.                        
  104.             if(($botones)>=3){
  105.                
  106.                 // next
  107.                 if((($this->Posicion)+1)>1 && ($this->Paginas)>1){
  108.                    
  109.                     echo '<input type="button" onClick="Paginacion('.($this-Posicion).')" value="<">';
  110.                    
  111.                 }
  112.                
  113.                 // numbers
  114.                 for($i = 1;$i<$botones;$i++){
  115.                
  116.                     if($i<$this->Paginas){
  117.                        
  118.                         echo '<input type="button" value="'.$i.'" onClick="Paginacion('.$i.')">';
  119.                            
  120.                     }
  121.                
  122.                 }
  123.                
  124.                 // prev
  125.                 if((($this->Posicion)+1)<($this->Paginas)){
  126.                    
  127.                     echo '<input type="button" onClick="Paginacion('.(($this->Posicion)+2).')" value=">">';
  128.                    
  129.                 }
  130.        
  131.             }
  132.            
  133.             if(($botones)<=2){
  134.            
  135.                        
  136.                 // next
  137.                 if((($this->Posicion+1))>1 && ($this->Paginas)>1){
  138.                    
  139.                     echo '<input type="button" onClick="Paginacion('.($this->Posicion).')" value=">">';
  140.                        
  141.                 }
  142.        
  143.                 // prev
  144.                 if((($this->Posicion)+1)<($this->Paginas)){
  145.                        
  146.                     echo '<input type="button" onClick="Paginacion('.(($this->Posicion)+2).')" value="<">';
  147.                        
  148.                 }
  149.                                
  150.             }
  151.            
  152.         }
  153.        
  154.     }


Código PHP:
Ver original
  1. # Framework
  2.     include("Cm_Framework.php");
  3.  
  4.     # Variables
  5.     $Convert = new Cm_Convert;
  6.    
  7.     #Datos
  8.     $Page = $Convert->ParseValInt(trim($_POST['Page']));
  9.    
  10.     # Paginador
  11.     $Paginador = new Cm_Paginador;
  12.     $Paginador->_Mysql(new Cm_mysql,'Eventos',5,'DESC',$Page);
  13.     $Paginador->_Estructure('<article class="Eventos"><i><img src="Content/Eventos/{Flyer}"></i><h1>{Titulo}</h1><p>{Info}</p><a href="/Eventos/{Slug}/">[+INFO]</a></article>');
  14.     $Paginador->_Devolucion();
  15.    
  16.     echo '<article class="Paginacion">';
  17.         $Paginador->_Navegacion(5);
  18.     echo '</article>';


Código Javascript:
Ver original
  1. /// ---- Paginacion eventos
  2. function Paginacion(pag){
  3.    
  4.     // -- Cargar eventos
  5.     $('section.Eventos').load('Include/Eventos.php',{'Page':pag});
  6.  
  7. }

Código PHP:
Ver original
  1. Notice: Use of undefined constant Posicion - assumed 'Posicion' in C:\xampp\htdocs\Levr\Include\Cm_Framework.php on line 519
  2.  
  3. Notice: Object of class Cm_Paginador could not be converted to int in C:\xampp\htdocs\Levr\Include\Cm_Framework.php on line 519



se que el error esta en la var posicion, pero yo veo a mi entendimiento que la estoy usando perfectamente :_.

[+INFO] El error solo me aparece si cambio de resultados, osea, paso de la pagina 1 a la 2 , los resultados si me los da, pero al final me devuelve el error :S

Grafico:

• Pag 1 = Resultados ok.
• Pag 2 = Resultados ok + error :S

Cualquier consejo, aporte, o solucion al problema sera de mucha ayuda , desde ya gracias :D


SOLUCIONADO:

Código PHP:
Ver original
  1. // next
  2.                 if((($this->Posicion)+1)>1 && ($this->Paginas)>1){
  3.                    
  4.                     echo '<input type="button" onClick="Paginacion('.($this-Posicion).')" value="<">';
  5.                    
  6.                 }

Por:

Código PHP:
Ver original
  1. // next
  2.                 if((($this->Posicion)+1)>1 && ($this->Paginas)>1){
  3.                    
  4.                     echo '<input type="button" onClick="Paginacion('.($this->Posicion).')" value="<">';
  5.                    
  6.                 }

Se me olvido el ">" xD perdon :_
  #2 (permalink)  
Antiguo 17/01/2013, 07:00
Avatar de maycolalvarez
Colaborador
 
Fecha de Ingreso: julio-2008
Ubicación: Caracas
Mensajes: 12.120
Antigüedad: 15 años, 8 meses
Puntos: 1532
Respuesta: Notice: Use of undefined constant [php]

seria preferible que nos indicaras la línea exacta en donde ocurre el Notice
__________________
¡Por favor!: usa el highlight para mostrar código
El que busca, encuentra...

Etiquetas: notice
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 08:06.