Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    Recuperare struttura categorie

    Ciao a tutti,
    ho la necessità di recuperare il percorso delle categorie un un e-commerce opencart.
    Ho creato una funzione che dovrebbe "tirare fuori" proprio l'elenco delle categorie.
    Purtroppo invece non funziona
    Ecco la funzione:
    Codice PHP:
    function getCat($child){
     
    $get_data2 "SELECT " DB_PREFIX "category_description.name, " DB_PREFIX "category.parent_id FROM " DB_PREFIX "category INNER JOIN " DB_PREFIX "category_description ON (" DB_PREFIX "category.category_id = " DB_PREFIX "category_description.category_id) WHERE " DB_PREFIX "category_description.language_id = 2 AND " DB_PREFIX "category.category_id = " $child;
      
    //print $get_data2;
      //exit;
      
      
    $result2 mysql_query($get_data2$conn);
      
      
    $row2 mysql_fetch_array($result2);
      
      
    $cat[] = $row2["name"];
      if(
    $row2["parent_id"] > 0){
       
    getCat($row2["parent_id"]);
      }
     
     return 
    implode("#"krsort($cat));

    Any help?

  2. #2
    Utente di HTML.it L'avatar di homerbit
    Registrato dal
    Dec 2005
    residenza
    Roma
    Messaggi
    1,380
    che tipo di errore?
    hai stampato la query? è corretta?
    If you think your users are idiots, only idiots will use it. DropBox

  3. #3
    La query stampata è
    Codice PHP:
    SELECT cc_category_description.namecc_category.parent_id FROM cc_category INNER JOIN cc_category_description ON (cc_category.category_id cc_category_description.category_idWHERE cc_category_description.language_id AND cc_category.category_id 65 
    che ovviamente restituisce sia un valore per il campo "name" che per quello "parent_id".
    Poi scoppia tutto in:
    codice:
    Warning:  mysql_query() expects parameter 2 to be resource, null given in...
    Warning:  mysql_fetch_array() expects parameter 1 to be resource, null given in...
    Sembrerebbe che il valore dle campo parent_id non venga passato, quando invece esso esiste.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.