elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado:


  Mostrar Temas
Páginas: [1]
1  Programación / PHP / poo php carrito en: 23 Noviembre 2016, 09:47 am
hola me aparece el siguiente mensaje de error intentando hacer un carrito de compras (que por cierto si tienen forma de ayudarme tirandome tips se los agradeceria): 

Código:
Notice: Undefined property: controladorproductos::$codigo in C:\xampp\htdocs\controlador.php on line 18

Fatal error: Call to a member function listar() on null in C:\xampp\htdocs\controlador.php on line 18


mis codigos:

conexion
Código:
<?php

class conexion{

     //Atributos

private $server;
private $usuario;
private $password;
private $bd;


//Metodo

public function __construct(){
          $this->server = "localhost";
          $this->usuario = "root";
          $this->password = "";
          $this->bd = "carro_productos";

          $con = mysql_errno($this->server, $this->usuario, $this->password);
          if ($con)
          mysql_select_db($this->bs, $con);
         

}

   public function consultaSimple($sql){
    $consulta = mysql_query($sql);
   }
     
      public function consultaRetorno($sql){
     
      }


   }




?>

productos
Código:
<?php

       include_once("conexion.php");
       include_once("carrito.php");
       include_once("controlador.php");
       include_once("enrutador.php");
       include_once("index.php");
       include_once("inicio.php");
       




       class productos{

        private $codigo;
        private $producto;
        private $descripcion;
        private $precio;

        private $con;

       }

?>

controlador

Código:
<?php

       
       include_once("productos.php");
     
       



       class controladorproductos{
         private $producto;

         public function __construct(){
           $this->productos = new productos();   
         }

         public function index(){
            $resultado = $this->codigo->listar();
            return $resultado;
         }
         public function eliminar($codigo){
            $this->producto->set("codigo", $codigo);
            $this->producto->eliminar();
         }
         public function ver($codigo){
            $this->producto->set("codigo", $codigo);
            $this->producto->ver();
         }

       }
?>

enrutador

Código:
<?php
include_once("conexion.php");
       include_once("carrito.php");
       include_once("controlador.php");
       include_once("enrutador.php");
       include_once("index.php");
       include_once("inicio.php");
       

class enrutador{
   public function vista($vista){
      switch ($vista):
         case 'añadir':
            include_once($vista . '.php');
            break;
         
        endswitch;
     
   }

  public function validarGET($var){
if(empty($var)){
   include_once('inicio.php');
}else{
   return true;
}
  }


    }


?>

index
Código:
<?php
        include_once("conexion.php");
       include_once("carrito.php");
       include_once("controlador.php");
       include_once("enrutador.php");
       include_once("index.php");
       include_once("inicio.php");
       


?>

<!DOCTYPE html>
<html>
<head>
   <meta charset="UTF-8"/>
   <title>Carrito</title>
</head>
<body>
     <h1>
        Carrito
     </h1>

     <section>
     <?php
      $enrutador = new enrutador();
      if($enrutador->validarGET($_GET['añadir'])){
        $enrutador->vista($_GET['añadir']);
      }
     
      ?>     
     </section>
</body>
</html>

inicio
Código:
<?php 
       include_once("conexion.php");
       include_once("carrito.php");
       
       include_once("enrutador.php");
       include_once("index.php");
       include_once("inicio.php");
       

       include_once("controlador.php");

       $controlador = new controladorproductos();
       $resultado = $controlador->index();
?>
<h3>pagina</h3>
<table>
<thead>
<th>codigo</th>
<th>producto</th>
<th>descripción</th>
<th>precio</th>
<th>acción</th>
</thead>
<tbody>
<?php while ($row = mysql_fetch_array($resultado)): ?>

<tr>
<td><?php echo $row['codigo']; ?></td>
<td><?php echo $row['producto']; ?></td>
<td><?php echo $row['descripción']; ?></td>
<td><?php echo $row['precio']; ?></td>
</tr>
<?php endwhile; ?>
</tbody>
</table>

Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines