Visualizzazione dei risultati da 1 a 6 su 6
  1. #1
    Utente di HTML.it
    Registrato dal
    May 2007
    Messaggi
    1,773

    mysql_fetch_assoc che stampa warning

    nuovamente buongiorno ,volevo domandarvi perche una query , stampa un errore warning posto l errore
    codice:
    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\Programmi\Apache Software Foundation\Apache2.2\htdocs\class_pager-2004-10-22\class.pager.example.php on line 20
    e la query:
    Codice PHP:
    $array mysql_query("SELECT * FROM tech  where staffid = staffid ");
    $result mysql_num_rows($array);
    if (isset(
    $_GET['page'])) { $page intval($_GET['page']); } else { $page 1; }

        
    $num_results $result //this value should arrive from some database query, like "select count(id) from table_you_want_to_page" 
        
    $per_page 1//number of results to be shown per page
        
    $query_string "class.pager.example.php?"// current file.. 
        
    echo $num_results ;
        
    $sql ="SELECT * FROM tech order by staffid asc limit $per_page , $num_result ";
        
    $query =  mysql_query($sql);
        while(
    $row mysql_fetch_assoc($query) )
        {
        echo 
    $row['nome'].'-'$row['cognome'].'-'$row['username'].'
    '
    ;
        }
        
        
    $pr = new pager($num_results$per_page$query_string); //building a pager
        
    $pr->num_results $result;
        
    $pr->per_page $per_page;
        
    $pr->query_string $query_string ;
    $range 9//set the range of page button list
    echo $pr->getButList($range); 

        
    $pr->getPageFrom($page); 
    Non è tanto importante saper fare,quanto ad avere voglia d imparare .

  2. #2
    Ti suggerisco di implementare il codice come suggerito nel manuale ufficiale:

    http://www.php.net/mysql_query Example #1 Invalid Query

  3. #3
    Utente di HTML.it
    Registrato dal
    May 2007
    Messaggi
    1,773
    ciao filippo scusa ma sto controllando , e l unico sbaglio c ci potrebbe essere secondo me e che non ho messo mysql_error
    Non è tanto importante saper fare,quanto ad avere voglia d imparare .

  4. #4
    Originariamente inviato da rocco.mod
    ciao filippo scusa ma sto controllando , e l unico sbaglio c ci potrebbe essere secondo me e che non ho messo mysql_error
    Facciamo così. Prova a seguire quanto suggerito e vediamo se il PHP ti fornisce qualche utile dettagli per risolvere il problema che sta affrontando.

  5. #5
    Utente di HTML.it
    Registrato dal
    May 2007
    Messaggi
    1,773
    sapessi l inglese
    Non è tanto importante saper fare,quanto ad avere voglia d imparare .

  6. #6
    Utente di HTML.it
    Registrato dal
    May 2007
    Messaggi
    1,773
    sembrera sciocco ma ora funziona comunque sarà una piccola sciocchezza ma l unica cosa che mi ha sugerito e stata di vedere i valori dell array con un print_r();

    però mi rimane sempre su un unico utente
    Non è tanto importante saper fare,quanto ad avere voglia d imparare .

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 © 2024 vBulletin Solutions, Inc. All rights reserved.