+ Rispondi alla Discussione
Risultati da 1 a 4 di 4

errore query

Ultimo Messaggio di Thedarkita il:
  1. #1
    dj è offline
    User Newbie
    Data Registrazione
    Jul 2015
    Località
    mia
    Messaggi
    7

    errore query

    ciao a tutti!

    Codice PHP:
    <?php
                                                                    mysql_query
    ("SET CHARACTER SET utf8");
                                                                    
    mysql_query("SET NAMES utf8");
                                                                    
    $rowsPerPage 20;
                                                                    
    $pageNum 1;
                                                                    if (isset(
    $_GET['page'])) {
                                                                        
    $pageNum $_GET['page'];
                                                                    }
                                                                    
    $offset = ($pageNum 1) * $rowsPerPage;
                                                                    
    $lettera=$_REQUEST['lettera'];
                                                                    if (
    $lettera == NULL) {
                                                                        
    $lettera '';
                                                                    } else {
                                                                        
    $lettera=$_REQUEST['lettera'];
                                                                    }
                                                                    if (
    $spec == NULL and $lettera == NULL and $tipo_medico == 1) {
                                                                        
    $Sqlqr_gl="select * from medici_chirurghi where cognome != '' order by IF (ASCII(LOWER(cognome)) >=ASCII (LOWER('$lettera')),1,2),cognome LIMIT $offset$rowsPerPage";
                                                                        
    $query="SELECT COUNT(m.id_albo) AS numrows from medici_chirurghi where cognome != ''";
                                                                    } else if (
    $spec == NULL and $lettera != NULL and $tipo_medico == 1) {
                                                                        
    $Sqlqr_gl="select * from medici_chirurghi where cognome != '' and cognome LIKE '$lettera%' order by cognome LIMIT $offset$rowsPerPage";
                                                                        
    $query="SELECT COUNT(m.id_albo) AS numrows from medici_chirurghi where cognome != '' and cognome LIKE '$lettera%'";
                                                                    } else if (
    $spec != NULL and $tipo_medico == 1) {
                                                                        
    $Sqlqr_gl="select m.* from medici_chirurghi m, matricola_specialita ms, specialita2 s where cognome != '' and s.id_spec = $spec and s.id_spec = ms.id_specialita and m.matricola2 = ms.matricola order by IF (ASCII(LOWER(cognome)) >=ASCII (LOWER('$lettera')),1,2),cognome LIMIT $offset$rowsPerPage";
                                                                        
    $query="SELECT COUNT(m.id_albo) AS numrows from medici_chirurghi m, matricola_specialita ms, specialita2 s where cognome != '' and s.id_spec = $spec and s.id_spec = ms.id_specialita and m.matricola2 = ms.matricola";
                                                                    } else if (
    $spec == NULL and $lettera == NULL and $tipo_medico == 2) {
                                                                        
    $Sqlqr_gl="select * from medici_odontoiatri where cognome != '' order by IF (ASCII(LOWER(cognome)) >=ASCII (LOWER('$lettera')),1,2),cognome LIMIT $offset$rowsPerPage";
                                                                        
    $query="SELECT COUNT(m.id_albo) AS numrows from medici_odontoiatri where cognome != ''";
                                                                    } else if (
    $spec == NULL and $lettera != NULL and $tipo_medico == 2) {
                                                                        
    $Sqlqr_gl="select * from medici_odontoiatri where cognome != '' and cognome LIKE '$lettera%' order by cognome  LIMIT $offset$rowsPerPage";
                                                                        
    $query="SELECT COUNT(m.id_albo) AS numrows from medici_odontoiatri where cognome != '' and cognome LIKE '$lettera%'";
                                                                    } else if (
    $spec != NULL  and $tipo_medico == 2) {
                                                                        
    $Sqlqr_gl="select m.* from medici_odontoiatri m, matricola_specialita ms, specialita2 s where cognome != '' and s.id_spec = $spec and s.id_spec = ms.id_specialita and m.matricola2 = ms.matricola order by IF (ASCII(LOWER(cognome)) >=ASCII (LOWER('$lettera')),1,2),cognome LIMIT $offset$rowsPerPage";
                                                                        
    $query="SELECT COUNT(m.id_albo) AS numrows from medici_odontoiatri m, matricola_specialita ms, specialita2 s where cognome != '' and s.id_spec = $spec and s.id_spec = ms.id_specialita and m.matricola2 = ms.matricola";
                                                                    }
                                                                    echo 
    "<div style=display:none>".$Sqlqr_gl."</div>";
                                                                    
    $qr_gl=mysql_query($Sqlqr_gl,$connessione)or die(mysql_error());
                                                                    while(
    $r_gl=mysql_fetch_array($qr_gl,MYSQL_ASSOC)) {
                                                                        if (
    $r_gl['cognome'] != NULL) {
                                                                            
    ?>
    Codice PHP:
    <?php 
                                                            
    if ($idmenu == '44') {
                                                                
    $tipo_medico '2';
                                                            } else if (
    $idmenu == '45') {
                                                                
    $tipo_medico '1';
                                                            }
                                                            
    $result=mysql_query($query) or die('Error, seconda query failed');
                                                            
    $row=mysql_fetch_array($resultMYSQL_ASSOC);
                                                            
    $numrows $row['numrows'];
                                                            
    $maxPage ceil($numrows/$rowsPerPage);
                                                            
    // print the link to access each page
                                                            
    $self $_SERVER['PHP_SELF'];
                                                            
    $nav '';
                                                            for(
    $page 1$page <= $maxPage$page++) {
                                                                if (
    $page == $pageNum) {
                                                                    
    $nav .= "<strong><a href='#'>.$page.</a></strong>"// no need to create a link to current page
                                                                
    } else {
                                                                    
    $nav .= " <a href=\"$self?page=$page&idmenu=$idmenu&lettera=$lettera&spec=$spec&tipomedico=$tipo_medico\">.$page.</a> ";
                                                                }
                                                            }
                                                            if (
    $pageNum 1) {
                                                                
    $page $pageNum 1;
                                                                
    $prev " <a href=\"$self?page=$page&idmenu=$idmenu&lettera=$lettera&spec=$spec&tipomedico=$tipo_medico\">&lt;</a> ";
                                                                
    $first " <a href=\"$self?page=1&idmenu=$idmenu&lettera=$lettera&spec=$spec&tipomedico=$tipo_medico\">[First Page]</a> ";
                                                            } else {
                                                                
    $prev  '&nbsp;'// we're on page one, don't print previous link
                                                                
    $first '&nbsp;'// nor the first page link
                                                            
    }
                                                            if (
    $pageNum $maxPage) {
                                                                
    $page $pageNum 1;
                                                                
    $next " <a href=\"$self?page=$page&idmenu=$idmenu&lettera=$lettera&spec=$spec&tipomedico=$tipo_medico\">&gt;</a> ";
                                                                
    $last " <a href=\"$self?page=$maxPage&idmenu=$idmenu&lettera=$lettera&spec=$spec&tipomedico=$tipo_medico\">[Last Page]</a> ";
                                                            } else {
                                                                
    $next '&nbsp;'// we're on the last page, don't print next link
                                                                
    $last '&nbsp;'// nor the last page link
                                                            
    }
                                                        
    ?>
    l errore è : Error, seconda query failed
    mi potreste dare una mano? grazie a tutti

  2. #2
    ModSenior L'avatar di Thedarkita
    Data Registrazione
    Aug 2006
    Località
    Messina
    Messaggi
    7,237
    Segui Thedarkita su Twitter Aggiungi Thedarkita su Google+ Aggiungi Thedarkita su Facebook Aggiungi Thedarkita su Linkedin Visita il canale Youtube di Thedarkita
    Ciao,
    invece di:
    Codice PHP:
    $result=mysql_query($query) or die('Error, seconda query failed'); 
    metti:
    Codice PHP:
    $result=mysql_query($query) or die('Error, seconda query failed: '.mysql_error()); 
    In maniera tale da visualizzare l'errore generato.

  3. #3
    dj
    dj è offline
    User Newbie
    Data Registrazione
    Jul 2015
    Località
    mia
    Messaggi
    7
    l errore è:
    Unknown column 'm.id_albo' in 'field list'

    grazie

  4. #4
    ModSenior L'avatar di Thedarkita
    Data Registrazione
    Aug 2006
    Località
    Messina
    Messaggi
    7,237
    Segui Thedarkita su Twitter Aggiungi Thedarkita su Google+ Aggiungi Thedarkita su Facebook Aggiungi Thedarkita su Linkedin Visita il canale Youtube di Thedarkita
    L'errore è nelle query come questa:
    Codice PHP:
    $query="SELECT COUNT(m.id_albo) AS numrows from medici_odontoiatri where cognome != '' and cognome LIKE '$lettera%'"
    Dove non esiste m

+ Rispondi alla Discussione

^ Permessi di Scrittura

  • Tu non puoi inviare nuove discussioni
  • Tu non puoi inviare risposte
  • Tu non puoi inviare allegati
  • Tu non puoi modificare i tuoi messaggi
  •  
  • Il codice BB è Attivato
  • Le faccine sono Attivato
  • Il codice [IMG] è Attivato
  • Il codice [VIDEO] è Attivato
  • Il codice HTML è Disattivato
  • Trackbacks Attivato
  • Pingback Attivato
  • Refback Attivato

SEO by vBSEO 3.6.0 PL2 ©2011, Crawlability, Inc.