Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it L'avatar di gabar-el
    Registrato dal
    Jun 2006
    Messaggi
    2,222

    errore sintassi mysql per via di offset....

    ciao, ho questo codice che sto provando che mi torna un errore, che reputo a $offset, come dice appunto l'errore stesso:
    codice php:
    Codice PHP:
    $offset $_REQUEST['offset'];
    $query "SELECT movie_name, movie_year
                FROM movie
                ORDER BY movie_name
                LIMIT 
    $offset,1";
    $results mysql_query($query)
        or die(
    mysql_error());
    echo 
    "<table>\n";
    while (
    $rows mysql_fetch_assoc($results)) {
    echo 
    "<tr>\n";
        foreach(
    $rows as $value) {
        echo 
    "<td>\n";
        echo 
    $value;
        echo 
    "</td>\n";
        }
    echo 
    "</tr>
    \n"
    ;
    }
    echo 
    "</table>\n";
    echo 
    "[url='page.php?offset=0']Page 1[/url]
    "
    ;
    echo 
    "[url='page.php?offset=1']Page 2[/url]
    "
    ;
    echo 
    "[url='page.php?offset=2']Page 3[/url]
    "

    errore:
    codice:
    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 '1' at line 4
    linea 4:
    Codice PHP:
    LIMIT $offset,1"; 
    grazie
    Si fanno sempre nuove scoperte

  2. #2
    prova a stampare la query:

    echo $query;

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

  3. #3
    Utente di HTML.it L'avatar di gabar-el
    Registrato dal
    Jun 2006
    Messaggi
    2,222
    me la torna così:
    codice:
    SELECT movie_name, movie_year FROM movie ORDER BY movie_name LIMIT ,1You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 4
    grazie
    Si fanno sempre nuove scoperte

  4. #4
    Originariamente inviato da gabar-el
    me la torna così:
    codice:
    SELECT movie_name, movie_year FROM movie ORDER BY movie_name LIMIT ,1You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 4
    grazie
    $offset e' vuoto.

    controlla il valore che trasferisci e in caso di "vuoto" mettici un default oppure segnala l'errore.

    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.