Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 16
  1. #1

    "Query was empty" che diavolo vuol dire? :cry:

    Salve oggi ho creato uno script ma mi da l'errore "Query was empty" qualcuno mi potrebbe aiutare io ho riguardato tutto...ecco il mio codice:

    Codice PHP:
    <?php
    //oggetto start
    ob_start();
    //sessione start
    session_start();
    /*recupero le variabili inviate tramite get e definisce la data corrente */
    $name $_GET[$nome];
    $data =  date("d/m/Y");
    $richiesta amicizia;
    //connesione al database
    include("config.ini.php");
    //query
    $id mysql_query("SELECT id FROM utenti WHERE nome = '".$name."'");
    if(!
    mysql_query($query,$dbh)) /*eseguo la query e controllo se va a buon fine ^^*/
    die("<h1>".mysql_error()."</h1>");

    $richiesta "INSERT INTO richieste.".$array['id']." (id_amico, tipo_richiesta, data_amicizia) VALUES ('".$session[id]."' , '".$richiesta."' , '".$data."')";
    if(!
    mysql_query($query,$dbh)) /*eseguo la query e controllo se va a buon fine ^^*/
    die("<h1>".mysql_error()."</h1>");
    mysql_close($dbh);
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
      <meta content="text/html; charset=ISO-8859-1"
     http-equiv="content-type">
      <title>Richiesta effetuata con sucesso</title>
    </head>
    <body>
    [img]loghi/logo.png[/img]













    <div style="text-align: center;">Richiesta inviata con
    sucesso[url="home.php"]torna alla home[/url]</div>
    </body>
    </html>

  2. #2
    Codice PHP:
    $richiesta "INSERT INTO richieste.".$array['id']." (id_amico, tipo_richiesta, data_amicizia) VALUES ('".$session[id]."' , '".$richiesta."' , '".$data."')";

    if(!
    mysql_query($query,$dbh)) 
    valorizzi $richiesta a poi usi $query .... diciamo che miracoli il software ancora non ne fa.

    ma poi detto tra noi ... dove prendi $array['id'] ??? ma e' solo una curiosita' ....

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

  3. #3

    Grandioso!

    Grandioso! ho sistemato lo script (da solo ) ma ora mi da questo errore, ma non ho capito bene cosa devo coreggere chi mi indirizza? ecco il mio codice ↨ ↨

    Codice PHP:
     <?php
    //oggetto start
    ob_start();
    //sessione start
    session_start();
    /*recupero le variabili inviate tramite get e definisce la data corrente */
    $name $_GET[$nome];
    $data =  date("d/m/Y");
    $richiesta amicizia;
    //connesione al database
    include("config.ini.php");
    //query
    $id mysql_query("SELECT id FROM utenti WHERE nome = '".$name."'");
    if(!
    mysql_query($id,$dbh)) /*eseguo la query e controllo se va a buon fine ^^*/
    die("<h1>".mysql_error()."</h1>");
    $array mysql_fetch_array($id); 

    $richiesta "INSERT INTO richieste.".$array['id']." (id_amico, tipo_richiesta, data_amicizia) VALUES ('".$session[id]."' , '".$richiesta."' , '".$data."')";
    if(!
    mysql_query($richiesta,$dbh)) /*eseguo la query e controllo se va a buon fine ^^*/
    die("<h1>".mysql_error()."</h1>");
    mysql_close($dbh);
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
      <meta content="text/html; charset=ISO-8859-1"
     http-equiv="content-type">
      <title>Richiesta effetuata con sucesso</title>
    </head>
    <body>
    [img]loghi/logo.png[/img]













    <div style="text-align: center;">Richiesta inviata con
    sucesso[url="home.php"]torna alla home[/url]</div>
    </body>
    </html>

  4. #4
    grandioso.

    ora vedi di sistemare da solo anche la seguente valorizzazione dell'array $richiesta

    codice:
    $richiesta = "INSERT INTO richieste.".$array['id']." 
                     (id_amico, tipo_richiesta, data_amicizia) 
                     VALUES 
                     ('".$session[id]."' , '".$richiesta."' , '".$data."')";
    Un suggerimento, a prescindere da tutto ... prova a stampare la variabile $richiesta con echo, conta anche quante volte appare $richiesta nelle righe qua sopra....

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

  5. #5

    Scusa, ho fatto un pò di confusione

    Inanzitutto grazie delle tue risposte e della tu pasienza
    Hai ragione, ho fatto confusione ocn le variabili! ho sistemato ma non credo che si quello l'errore, perchè, lo script non funge, mi continua ad uscire l'errore precendente ovvero:
    "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 'Resource id #4' at line 1"
    lo script è il seguente

    Codice PHP:
    <?php
    //oggetto start
    ob_start();
    //sessione start
    session_start();
    /*recupero le variabili inviate tramite get e definisce la data corrente */
    $name $_GET[$nome];
    $data =  date("d/m/Y");
    $tipo amicizia;
    //connesione al database
    include("config.ini.php");
    //query
    $id mysql_query("SELECT id FROM utenti WHERE nome = '".$name."'");
    if(!
    mysql_query($id,$dbh)) /*eseguo la query e controllo se va a buon fine ^^*/
    die("<h1>".mysql_error()."</h1>");
    $array mysql_fetch_array($id);

    $richiesta "INSERT INTO richieste.".$array['id']." (id_amico, tipo_richiesta, data_amicizia) VALUES ('".$session[id]."' , '".$tipo."' , '".$data."')";
    if(!
    mysql_query($richiesta,$dbh)) /*eseguo la query e controllo se va a buon fine ^^*/
    die("<h1>".mysql_error()."</h1>");
    mysql_close($dbh);
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
      <meta content="text/html; charset=ISO-8859-1"
     http-equiv="content-type">
      <title>Richiesta effetuata con sucesso</title>
    </head>
    <body>
    [img]loghi/logo.png[/img]













    <div style="text-align: center;">Richiesta inviata con
    sucesso[url="home.php"]torna alla home[/url]</div>
    </body>
    </html>

  6. #6
    Se non dici l'errore che ricevi .... dunque: stai utilizzando il resource id number con query.
    ha ragione ad indispettirsi.

    Codice PHP:
    $id mysql_query("SELECT id FROM utenti WHERE nome = '".$name."'");
    if(!
    mysql_query($id,$dbh)) /*eseguo la query e controllo se va a buon fine ^^*/ 
    dentro a $id non hai nessuna query. E non mi chiedere cosa dovrebbe esserci ti risponderei "la query" ... come puoi vedere tu stesso esegui due volte mysql_query

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

  7. #7
    bene ora dice:

    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 '(id_amico, tipo_richiesta, data_amicizia) VALUES ('', 'amicizia'

    lo script è:

    Codice PHP:
    <?php
    //oggetto start
    ob_start();
    //sessione start
    session_start();
    /*recupero le variabili inviate tramite get e definisce la data corrente */
    $name $_GET[$nome];
    $data =  date("d/m/Y");
    $tipo amicizia;
    //connesione al database
    include("config.ini.php");
    //query
    $id "SELECT id FROM utenti WHERE nome = '".$name."'";
    if(!
    mysql_query($id,$dbh)) /*eseguo la query e controllo se va a buon fine ^^*/
    die("<h1>".mysql_error()."</h1>");
    $array mysql_fetch_array($id);

    $richiesta "INSERT INTO richieste.".$array['id']." (id_amico, tipo_richiesta, data_amicizia) VALUES ('".$session[id]."', '".$tipo."', '".$data."')";
    if(!
    mysql_query($richiesta,$dbh)) /*eseguo la query e controllo se va a buon fine ^^*/
    die("<h1>".mysql_error()."</h1>");
    mysql_close($dbh);
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
      <meta content="text/html; charset=ISO-8859-1"
     http-equiv="content-type">
      <title>Richiesta effetuata con sucesso</title>
    </head>
    <body>
    [img]loghi/logo.png[/img]













    <div style="text-align: center;">Richiesta inviata con
    sucesso[url="home.php"]torna alla home[/url]</div>
    </body>
    </html>

  8. #8
    cosa ti stampa:

    echo $richiesta;

    dopo la variabile e prima di mysql_query. Hai il nome errato della tabella

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

  9. #9
    si hai ragione per l'ennesima ovlta sono uno stupido forse è meglio che contini a studiare meglio il php comunque ti chiedo un ultima cosa che sui libri non è scritta in questa righa
    Codice PHP:
    INSERT INTO richieste.".$array['id']." 
    io richiamo la tabella richieste con l'id utente ad es: richieste6 ora il fatto è che l'id non funge ho provato a fare anche un echo con la qurery che recuèera l'id ma niente NON MI DA NESSUN ERRORE RIMANE SEMLICEMENTE LA PAGINA BIANCA...hai qualche idea? :master:

  10. #10
    Codice PHP:
    INSERT INTO richieste.".$array['id']." 
    cosi' come e' scritto significa database richieste tabella descritta in $array['id']

    la sintassi e' in pratica nome database . nome tabella, ma ho dei fortissimi dubbi che una tabella abbia come nome un id di un record della tabella utenti. Dovresti avere tante tabelle quanti sono gli id.

    Una pagina rimane bianca quando ricevi un errore dal parser e non hai abilitato la stampa degli errori.

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