Visualizzazione dei risultati da 1 a 5 su 5

Discussione: query errata

  1. #1

    query errata

    Ciao a tutti!!!

    Questa query mi restituisce un errore nella riga:

    $rows = mysql_num_rows($query);

    Questo è l'errore
    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\programmi\apache group\apache\test\igratis\prove\untitled2.php on line 505


    Questa è la query:
    $sql=" SELECT * ";
    $sql.=" FROM (annunci INNER JOIN utenti ON annunci.IDutente = utenti.IDutente ";
    $sql.=" WHERE Testo LIKE '%%%$cerca%%%' and IDcateg=$tipologia2 ";
    $sql.=" ORDER BY DataIns DESC , IDannuncio DESC ";
    $query = mysql_query($sql);
    $rows = mysql_num_rows($query);
    $sql.=" LIMIT $limit, $annunci_pagina";
    $query = mysql_query($sql);

    Qualcuno mi sa dire il perchè??
    Dove sto sbaglaindo?


  2. #2
    Si potrebbe ipotizzare....

    ma perche' non sfrutti la possibilita' di evidenziare l'errore?

    $query = mysql_query($sql) or die(mysql_error());

    in entrambe le queries (???) ovviamente.


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

  3. #3
    Utente di HTML.it
    Registrato dal
    May 2004
    Messaggi
    56
    Manca la parentesi tonda di chiusura ')' alla 'From'

  4. #4
    se io sostituisco:

    $sql.=" FROM (annunci INNER JOIN utenti ON annunci.IDutente = utenti.IDutente ";

    con questo:

    $sql.=" FROM annunci ";

    la query funziona perfettamente

    ora la riscrivo:
    Codice PHP:
    $sql=" SELECT * ";
    $sql.=" FROM (annunci INNER JOIN utenti ON annunci.IDutente = utenti.IDutente ";
    $sql.=" WHERE Testo LIKE '%%%$cerca%%%' and IDcateg=$tipologia2 ";
    $sql.=" ORDER BY DataIns DESC , IDannuncio DESC ";
    $query mysql_query($sql)or die(mysql_error()); ;
    $rows mysql_num_rows($query);
    $sql.=" LIMIT $limit$annunci_pagina";
    $query mysql_query($sql)or die(mysql_error()); ; 
    Una domanda ma è possibile mettere l'inner join con il like?

  5. #5
    Sistemato ciao

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.