Visualizzazione dei risultati da 1 a 10 su 10
  1. #1
    Utente bannato L'avatar di 3com_mr
    Registrato dal
    Jan 2006
    Messaggi
    130

    Errore Mysql - mysql_num_rows()

    Salve,

    ho ricevuto il seguente errore:

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /xxx/view.php on line 55

    La riga in questione è

    Codice PHP:
    if(mysql_num_rows($r) == 0) echo "

    Nessun risultato...</p>"

    il blocco di riferimento è

    Codice PHP:
          <?php
              $q 
    "select * from hotels where id=".$_GET['ref'];
              
    $r mysql_query($q);
              if(
    mysql_num_rows($r) == 0) echo "

    Nessun risultato...</p>"
    ;
              else
              { 
                
    $riga mysql_fetch_assoc($r);
          
    ?>

    dov'è l'errore?

  2. #2

    Re: Errore Mysql - mysql_num_rows()

    Originariamente inviato da 3com_mr
    Salve,

    ho ricevuto il seguente errore:

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /xxx/view.php on line 55

    dov'è l'errore?
    metti la segnalazione di errore alla query.

    $r = mysql_query($q) or die(mysql_error()) ;

    Il silenzio è spesso la cosa migliore. Pensa ... è gratis.

  3. #3
    Utente bannato L'avatar di 3com_mr
    Registrato dal
    Jan 2006
    Messaggi
    130
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

  4. #4
    Originariamente inviato da 3com_mr
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
    codice:
    $q = "select * from hotels where id = '$_GET[ref]' ";
    prova cosi'

    Il silenzio è spesso la cosa migliore. Pensa ... è gratis.

  5. #5
    Utente bannato L'avatar di 3com_mr
    Registrato dal
    Jan 2006
    Messaggi
    130
    grazie, funziona ma ho ancora un errore...

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\'%%\' and region like \'%%\' and province like \'%%\' and city like \'%milano%\' at line 1

    qui

    Codice PHP:
     $q "select count(*) from hotels where 1 ";
                
    $r mysql_query($q.$where);
    88         $count mysql_result($r,0,"count(*)") or die(mysql_error()) ;
                
    $pages ceil($count/$PERPAGINA);
                
    $from = ($currentPage-1)*$PERPAGINA

  6. #6
    l'errore non e' nella query che hai postato.

    l'errore richiama chiaramente una stringa diversa.

    Il silenzio è spesso la cosa migliore. Pensa ... è gratis.

  7. #7
    Utente bannato L'avatar di 3com_mr
    Registrato dal
    Jan 2006
    Messaggi
    130
    oibò...

    e come la pesco?

  8. #8
    Originariamente inviato da 3com_mr
    oibò...

    e come la pesco?
    deve esserci una stringa di questo tipo:

    ..... ''%%' and region like '%%' and province like '%%' and city like '%milano%'

    dovrebbe trovarsi in un WHERE oppure raccolto in una variabile che viene passata al where.

    ..... la variabile $where

    Il silenzio è spesso la cosa migliore. Pensa ... è gratis.

  9. #9
    Utente bannato L'avatar di 3com_mr
    Registrato dal
    Jan 2006
    Messaggi
    130
    allora qui

    Codice PHP:
    if(isset($_POST['invia']) || isset($_GET['page']))
              {
                
    $currentPage = (!$_GET['page'])?1:(int)$_GET['page'];
                
    $where "";
      
                if(isset(
    $_POST['name'])) $where.= "and name like '%".$_POST['name']."%' ";
                if(isset(
    $_POST['rating'])) $where.= "and rating = '".$_POST['rating']."' ";
                if(isset(
    $_POST['region'])) $where.= "and region like '%".$_POST['region']."%' ";
                if(isset(
    $_POST['province'])) $where.= "and province like '%".$_POST['province']."%' ";
                if(isset(
    $_POST['city'])) $where.= "and city like '%".$_POST['city']."%' ";
                
                if(!isset(
    $_GET['page'])) $_SESSION['where'] = $where;
                
    $where = ($_POST['where'] != "") ? $_POST['where'] : $_SESSION['where']; 

  10. #10
    stampa la query.

    codice:
    $q = "select count(*) from hotels where 1 ";
    echo $q.$where
    
                $r = mysql_query($q.$where) or die(mysql_error());

    Il silenzio è spesso la cosa migliore. Pensa ... è gratis.

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.