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

 

 


Tema destacado: Introducción a Git (Primera Parte)


+  Foro de elhacker.net
|-+  Programación
| |-+  Desarrollo Web
| | |-+  PHP (Moderador: #!drvy)
| | | |-+  falla al momento de agregar marca
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: falla al momento de agregar marca  (Leído 1,809 veces)
geshiro

Desconectado Desconectado

Mensajes: 178


Ver Perfil
falla al momento de agregar marca
« en: 10 Abril 2016, 19:05 pm »

al momento de querer agregar un producto ya bien junto con la marca si lo hace si en esta linea lo cambio por el id que es la marca en formato numerico
Código
  1. $brand =  $result->getBrandById($_POST['brand']);
solo que se ya como pasarle la instancia para que lo agrege de forma dinamica ya que ahorita esta statico por el error la consulta esta bien pero la variable de $brand digo que tmb esta bien asi que no se de que parte este mal



controller product.php
Código
  1. case 'add_product':
  2. $result = new brand();
  3. $code    = trim(stripslashes(htmlspecialchars($_POST['code'])));
  4. $product = trim(stripslashes(htmlspecialchars($_POST['product'])));
  5. $brand =  $result->getBrandById($_POST['brand']);
  6. $price   = trim(stripslashes(htmlspecialchars($_POST['price'])));
  7. $stock   = trim(stripslashes(htmlspecialchars($_POST['stock'])));
  8. $newProduct = new product();
  9. if($newProduct->add($code,$product,$brand,$price,$stock)){
  10. echo "success";
  11. }
  12. else{
  13. echo "No se registro";
  14. }
  15. break;
  16.  
  17.  

model brand.php
Código
  1. function getBrandById($id){
  2. $sql = "SELECT idbrand,brand FROM brand WHERE idbrand = {$id}";
  3. $result = $this->conexion->conexion->query($sql);
  4. $array = array();
  5. while($record = $result->fetch_array(MYSQL_NUM)){
  6. //$a = $record;
  7. //var_dump($a);
  8. $array[] = $record;
  9. }
  10. return $array;
  11. $this->conexion->cerrar();
  12. }
  13. }
  14.  


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines